@fluixi/reactive 1.0.0-alpha.82 → 1.0.0-alpha.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/cdn/signal.cjs +1 -1
- package/dist/cdn/signal.global.js +1 -1
- package/dist/cdn/signal.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/api.cjs +1 -1
- package/dist/lib/signal/api.mjs +1 -1
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/children.cjs +1 -1
- package/dist/lib/signal/graph/children.mjs +1 -1
- package/dist/lib/signal/graph/compat.cjs +1 -1
- package/dist/lib/signal/graph/compat.d.ts.map +1 -1
- package/dist/lib/signal/graph/compat.js +19 -2
- package/dist/lib/signal/graph/compat.mjs +1 -1
- package/dist/lib/signal/graph/core.cjs +1 -1
- package/dist/lib/signal/graph/core.d.ts.map +1 -1
- package/dist/lib/signal/graph/core.js +7 -0
- package/dist/lib/signal/graph/core.mjs +1 -1
- package/dist/lib/signal/graph/debounced.cjs +1 -1
- package/dist/lib/signal/graph/debounced.mjs +1 -1
- package/dist/lib/signal/graph/derived.cjs +1 -1
- package/dist/lib/signal/graph/derived.mjs +1 -1
- package/dist/lib/signal/graph/error-boundary.cjs +1 -1
- package/dist/lib/signal/graph/error-boundary.mjs +1 -1
- package/dist/lib/signal/graph/index.cjs +1 -1
- package/dist/lib/signal/graph/index.mjs +1 -1
- package/dist/lib/signal/graph/observe.cjs +1 -0
- package/dist/lib/signal/graph/observe.d.ts +141 -0
- package/dist/lib/signal/graph/observe.d.ts.map +1 -0
- package/dist/lib/signal/graph/observe.js +149 -0
- package/dist/lib/signal/graph/observe.mjs +1 -0
- package/dist/lib/signal/graph/resource.cjs +1 -1
- package/dist/lib/signal/graph/resource.mjs +1 -1
- package/dist/lib/signal/graph/runtime.cjs +1 -1
- package/dist/lib/signal/graph/runtime.d.ts +2 -2
- package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
- package/dist/lib/signal/graph/runtime.js +22 -7
- package/dist/lib/signal/graph/runtime.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +1 -1
- package/dist/lib/signal/graph/signal-next.mjs +1 -1
- package/dist/lib/signal/graph/state.cjs +1 -1
- package/dist/lib/signal/graph/state.d.ts +2 -0
- package/dist/lib/signal/graph/state.d.ts.map +1 -1
- package/dist/lib/signal/graph/state.js +1 -0
- package/dist/lib/signal/graph/state.mjs +1 -1
- package/dist/lib/signal/graph/suspense.cjs +1 -1
- package/dist/lib/signal/graph/suspense.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.d.ts +2 -0
- package/dist/lib/signal/index.d.ts.map +1 -1
- package/dist/lib/signal/index.js +2 -0
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/list.cjs +1 -1
- package/dist/lib/signal/list.js +5 -5
- package/dist/lib/signal/list.mjs +1 -1
- package/dist/lib/signal/resource-api.cjs +1 -1
- package/dist/lib/signal/resource-api.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/lib/signal/utilities.cjs +1 -1
- package/dist/lib/signal/utilities.mjs +1 -1
- package/dist/lib/store/api.cjs +1 -1
- package/dist/lib/store/api.mjs +1 -1
- package/dist/lib/store/index.cjs +1 -1
- package/dist/lib/store/index.mjs +1 -1
- package/dist/lib/store/store.cjs +1 -1
- package/dist/lib/store/store.d.ts.map +1 -1
- package/dist/lib/store/store.js +148 -8
- package/dist/lib/store/store.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +1 -1
- package/package.json +2 -2
package/dist/lib/signal/api.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var T=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var $=(e,n)=>{for(var t in n)T(e,t,{get:n[t],enumerable:!0})},U=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of L(n))!Y.call(e,i)&&i!==t&&T(e,i,{get:()=>n[i],enumerable:!(o=F(n,i))||o.enumerable});return e};var B=e=>U(T({},"__esModule",{value:!0}),e);var ce={};$(ce,{effect:()=>ae,memo:()=>ue,signal:()=>se});module.exports=B(ce);var X="__fluixi_signal_next_state__",J=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[X]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:J,onSuspend:null,onError:null,observer:null};var R="1.0.0-alpha.83";function Q(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var b=[],Z;function d(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:b,origin:e.origin??Z}:e)}function C(e){return r.observer?(b.push(e),!0):!1}function q(){b.pop()}function D(e){r.observer?.ran?.(e)}function N(e,n){r.observer?.wrote?.(e,n)}function p(e){r.observer?.disposed?.(e)}var ee="__FLUIXI_DEVTOOLS_HOOK__",_=globalThis[ee];if(typeof _?.inject=="function")try{_.inject({observeReactiveNodes:Q,version:R})}catch{}function m(){return r.observer!=null}var A=0,E=1,f=2,v=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},h=class extends v{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++,N(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(f);x(this)}}peek(){return this._value}},c=class extends v{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=f;this.sources=null;this._fn=t,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===E&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===f)break}(this.state===f||!this._initialized)&&this.recompute(),this.state=A}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked,i=C(this);r.consumer=this,r.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(l){u=!0,a=l,s=this._value}finally{r.consumer=t,r.untracked=o,i&&q()}let K=!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,D(this),K){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(f);x(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===A;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(E);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 w=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 ne(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function P(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function H(){return r.owner}function k(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function S(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function g(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)g(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 M(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function te(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 n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function I(){r.batchDepth===0&&O()}var y=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=ne(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{g(this.owner,!1),k(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),d({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new w(()=>te(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"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,p(this.computed),this.watcher.unwatch(this.computed),g(this.owner))}};function j(e,n=!1){let t=new y(e,n);return()=>t.dispose()}function re(e){return!!e&&typeof e.then=="function"}M(()=>{});var W=Symbol.for("signal"),oe=Symbol.for("memo"),ie=Symbol.for("signal-node");function V(e,n){let t=new h(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),I(),u});return Object.defineProperty(o,W,{value:!0,enumerable:!0}),Object.defineProperty(o,ie,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),d({kind:"signal",node:t,handle:o,name:n?.name,set:i}),m()&&S(()=>p(t)),[o,i]}function G(e,n,t){let o=n,i=H(),s=new c(()=>k(i,()=>{try{return o=e(o)}catch(a){if(re(a))return P(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,W,{value:!0,enumerable:!0}),Object.defineProperty(u,oe,{value:!0,enumerable:!0}),d({kind:"memo",node:s,handle:u,name:t?.name}),m()&&S(()=>p(s)),u}function z(e,n){let t=n;return j(()=>{t=e(t)},!0)}function se(e,n){let[t,o]=V(e,n);return Object.assign(t,{set:o})}function ue(e,n,t){return G(e,n,t)}function ae(e,n){return z(e,n)}
|
package/dist/lib/signal/api.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K="__fluixi_signal_next_state__",F=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[K]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:F,onSuspend:null,onError:null,observer:null};var O="1.0.0-alpha.83";function L(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var T=[],Y;function d(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:T,origin:e.origin??Y}:e)}function _(e){return r.observer?(T.push(e),!0):!1}function C(){T.pop()}function q(e){r.observer?.ran?.(e)}function D(e,n){r.observer?.wrote?.(e,n)}function p(e){r.observer?.disposed?.(e)}var $="__FLUIXI_DEVTOOLS_HOOK__",R=globalThis[$];if(typeof R?.inject=="function")try{R.inject({observeReactiveNodes:L,version:O})}catch{}function b(){return r.observer!=null}var N=0,A=1,f=2,v=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},h=class extends v{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++,D(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(f);m(this)}}peek(){return this._value}},c=class extends v{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=f;this.sources=null;this._fn=t,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===A&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===f)break}(this.state===f||!this._initialized)&&this.recompute(),this.state=N}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked,u=_(this);r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(l){s=!0,a=l,i=this._value}finally{r.consumer=t,r.untracked=o,u&&C()}let z=!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,q(this),z){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(f);m(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===N;if(this.state=t,o){if(this.observers)for(let u of[...this.observers])u.markDirty(A);m(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function m(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var w=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){return{cleanups:null,owned:null,parent:e,contexts:null}}function E(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function P(){return r.owner}function y(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function k(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function x(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)x(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 H(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function B(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(S)))}function S(){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 n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function M(){r.batchDepth===0&&S()}var g=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=U(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{x(this.owner,!1),y(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),d({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new w(()=>B(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"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,p(this.computed),this.watcher.unwatch(this.computed),x(this.owner))}};function I(e,n=!1){let t=new g(e,n);return()=>t.dispose()}function X(e){return!!e&&typeof e.then=="function"}H(()=>{});var j=Symbol.for("signal"),J=Symbol.for("memo"),Q=Symbol.for("signal-node");function W(e,n){let t=new h(e,{equals:n?.equals}),o=(()=>t.get()),u=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),M(),s});return Object.defineProperty(o,j,{value:!0,enumerable:!0}),Object.defineProperty(o,Q,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),d({kind:"signal",node:t,handle:o,name:n?.name,set:u}),b()&&k(()=>p(t)),[o,u]}function V(e,n,t){let o=n,u=P(),i=new c(()=>y(u,()=>{try{return o=e(o)}catch(a){if(X(a))return E(a),o;throw a}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,j,{value:!0,enumerable:!0}),Object.defineProperty(s,J,{value:!0,enumerable:!0}),d({kind:"memo",node:i,handle:s,name:t?.name}),b()&&k(()=>p(i)),s}function G(e,n){let t=n;return I(()=>{t=e(t)},!0)}function xe(e,n){let[t,o]=W(e,n);return Object.assign(t,{set:o})}function ge(e,n,t){return V(e,n,t)}function ye(e,n){return G(e,n)}export{ye as effect,ge as memo,xe as signal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ce=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)ce(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&&ce(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Xe=e=>Ye(ce({},"__esModule",{value:!0}),e);var Rt={};Ke(Rt,{clearAllCachedResources:()=>Ot,clearCachedResourceNamespace:()=>gt,createCachedResource:()=>St});module.exports=Xe(Rt);function fe(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ce(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function de(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(fe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ce(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(fe(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new pe(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 Je=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?Je:!1,Qe=Symbol.for("signal");function he(e){return typeof e=="function"&&e[Qe]===!0}var Ze="__fluixi_signal_next_state__",et=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Ze]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:et,onSuspend:null,onError:null};var _e=0,Ae=1,J=2,ve=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 Q=class extends ve{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===Ae&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=_e}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);Pe(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===_e;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ae);Pe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Pe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Fe(){return h.owner}function ke(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function De(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function tt(e){return!!e&&typeof e.then=="function"}De(()=>{});var nt=Symbol.for("signal"),rt=Symbol.for("memo");function Z(e,t,n){let o=t,r=Fe(),s=new Q(()=>ke(r,()=>{try{return o=e(o)}catch(f){if(tt(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,nt,{value:!0,enumerable:!0}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),a}function ee(e){if(typeof e=="function"&&!e.length){let t=e();return he(t)?t:ee(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=ee(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Z(e);return X?Z(()=>ee(t()),void 0,{name:"children"}):Z(()=>ee(t()))}var Ne=null;function Te(e){Ne&&Ne(e)}var ot=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),st=Symbol.for("signal-node"),G=0,be=1,oe=2,I=3,c=null,v=null,i=null,ne=null,re=0,it=!1,ye=!1,N=0,ut=1e6,O=new WeakMap,te=null;var at=new Map,lt=0;function ct(){return`node_${++lt}_${Date.now()}`}function ft(e){X&&at.set(e.id,new WeakRef(e))}function dt(e,t,n){let o={id:ct(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ft(o),o}function pt(e,t){return e===t}function Le(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function ht(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(te&&te.running&&!e.pure)te.effects.indexOf(e)===-1&&te.effects.push(e);else if(!e.pure||e.computed)we(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;se(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=dt("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||pt;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,ie=!1){let m=l.state;if(!(m===I&&l===v)){if(ie&&!l.pure){m===G&&(l.state=be,it&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=oe,m===G||m===be?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var V=F;let E=Array.from(R),x=[],S=new Set;Ue(E,F);for(let l of x)ht(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return me(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,ot,{value:!0,enumerable:!0}),Object.defineProperty(a,st,{value:o,enumerable:!1}),r}function me(e,t,n){let o={fn:e,state:oe,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,re++,re>ut)throw re=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(de(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 we(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===oe||e.state===be||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?je(e):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 se(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)&&we(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 se(n),i=r,o}N++,i=[],ne=[];try{return e()}finally{N--,vt()}}function vt(){if(!ye){ye=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,ne){let e=ne;ne=null;for(let t=0;t<e.length;t++)we(e[t])}}finally{ye=!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 Tt(e){let t=Symbol("context"),n=yt(t);return{id:t,Provider:n,defaultValue:e}}function yt(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 bt(()=>{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 bt(e,t,n){let o={fn:e,state:oe,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),je(o),()=>U(o)}function je(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(de(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;se(r),i=s}}}var w;function Ge(){return w||(w=Tt())}var P=new Map,A=new Map,mt=0,wt=Symbol.for("signal"),xt=Symbol.for("resource");function St(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_${mt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,E]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ve,xe]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function Se(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||ge(p,y)},p=>{!g()&&!y&&Oe(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(P.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){Te(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||ge(p,y)},p=>{!g()&&!y&&Oe(p)})}function ge(u,T){_(()=>{E(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Oe(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;me(()=>{z===void 0&&(z=Ge());let u=o();if(Ve(),u===!1||u===null||u===void 0){W=ue,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let g=B(u);y&&P.delete(g);let D=W===ue||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=P.get(g);if(q&&V(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{E(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{E(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),Se(u,g,!0,()=>p);return}let Re=L(x),$e=Re==="ready"||Re==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),Se(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(H,xt,{value:!0,enumerable:!0}),Object.defineProperty(H,wt,{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:E,refetch:()=>{ae=!0,xe(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&P.delete(B(u)),le=!0,xe(T=>T+1)}}]}function gt(e){let t=`${e}:`;for(let n of P.keys())n.startsWith(t)&&P.delete(n)}function Ot(){P.clear(),A.clear()}
|
|
1
|
+
"use strict";var ce=Object.defineProperty;var nn=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var rn=Object.prototype.hasOwnProperty;var on=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},sn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of tn(n))!rn.call(e,r)&&r!==t&&ce(e,r,{get:()=>n[r],enumerable:!(o=nn(n,r))||o.enumerable});return e};var un=e=>sn(ce({},"__esModule",{value:!0}),e);var Mn={};on(Mn,{clearAllCachedResources:()=>Ln,clearCachedResourceNamespace:()=>Un,createCachedResource:()=>In});module.exports=un(Mn);function fe(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function ke(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function de(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(fe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(ke(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(fe(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var K=class extends j{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},pe=class extends K{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof K?r=n:r=new pe(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var an=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?an:!1,ln=Symbol.for("signal");function ve(e){return typeof e=="function"&&e[ln]===!0}var cn="__fluixi_signal_next_state__",fn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[cn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fn,onSuspend:null,onError:null,observer:null};var _e="1.0.0-alpha.83";function dn(e){return a.observer=e,()=>{a.observer===e&&(a.observer=null)}}var he=[],pn;function Ee(e){let n=a.observer;n&&n.created(e.parents===void 0?{...e,parents:he,origin:e.origin??pn}:e)}function Pe(e){return a.observer?(he.push(e),!0):!1}function Fe(){he.pop()}function De(e){a.observer?.ran?.(e)}function qe(e){a.observer?.disposed?.(e)}var vn="__FLUIXI_DEVTOOLS_HOOK__",Ae=globalThis[vn];if(typeof Ae?.inject=="function")try{Ae.inject({observeReactiveNodes:dn,version:_e})}catch{}function Ne(){return a.observer!=null}var Ie=0,Ue=1,J=2,be=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}};var Q=class extends be{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ue&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ie}recompute(){if(this.sources){for(let v of this.sources)v.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked,r=Pe(this);a.consumer=this,a.untracked=!1;let s,l=!1,d;try{s=this._fn()}catch(v){l=!0,d=v,s=this._value}finally{a.consumer=t,a.untracked=o,r&&Fe()}let b=!this._initialized||this._threw!==l||(l?d!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=l,this._error=d,this._value=s,De(this),b){if(this.version++,this.observers)for(let v of[...this.observers])v.markDirty(J);Le(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Ie;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ue);Le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Le(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}function Me(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Be(){return a.owner}function je(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function Ve(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Ge(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function hn(e){return!!e&&typeof e.then=="function"}Ge(()=>{});var bn=Symbol.for("signal"),Tn=Symbol.for("memo");function Z(e,n,t){let o=n,r=Be(),s=new Q(()=>je(r,()=>{try{return o=e(o)}catch(d){if(hn(d))return Me(d),o;throw d}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,bn,{value:!0,enumerable:!0}),Object.defineProperty(l,Tn,{value:!0,enumerable:!0}),Ee({kind:"memo",node:s,handle:l,name:t?.name}),Ne()&&Ve(()=>qe(s)),l}function ee(e){if(typeof e=="function"&&!e.length){let n=e();return ve(n)?n:ee(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ee(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function $e(e){let n=Z(e);return X?Z(()=>ee(n()),void 0,{name:"children"}):Z(()=>ee(n()))}var We=null;function Te(e){We&&We(e)}var yn=Symbol.for("signal");var He=Symbol("fluixi-proxy"),mn=Symbol.for("signal-node"),V=0,me=1,oe=2,I=3,f=null,h=null,i=null,te=null,re=0,wn=!1,ye=!1,N=0,xn=1e6,O=new WeakMap,ne=null;var gn=new Map,Sn=0;function On(){return`node_${++Sn}_${Date.now()}`}function Rn(e){X&&gn.set(e.id,new WeakRef(e))}function Cn(e,n,t){let o={id:On(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Rn(o),o}function kn(e,n){return e===n}function Ke(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function _n(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ne&&ne.running&&!e.pure)ne.effects.indexOf(e)===-1&&ne.effects.push(e);else if(!e.pure||e.computed)xe(e);else if(e.pure&&!e.computed&&e.accessor){let n=h,t=i;h=null,i=[],e.accessor(),h=n;let o=i;if(i=t,o.length>0){let r=i;se(o),i=r}}}function ze(e,n){for(let t=0;t<e.length;t++)n(e[t])}function C(e,n){let t=e;typeof t=="object"&&t&&He in t&&delete t[He];let o=Cn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,d];O.set(r,new Set);let s;function l(){let b=h;if(b){b.sources?b.sources.indexOf(r)===-1&&b.sources.push(r):b.sources=[r];let v=O.get(r);v&&!v.has(b)&&v.add(b)}return t}function d(b){let v=typeof b=="function"?b(t):b,B=o.equals||kn;if(n?.equals===!1||!B(t,v)){t=v,o.value=v,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let P=function(c,ie=!1){let m=c.state;if(!(m===I&&c===h)){if(ie&&!c.pure){m===V&&(c.state=me,wn&&(i!==null&&i.indexOf(c)===-1?i.push(c):x.push(c)));return}if(!g.has(c)&&(g.add(c),c.state=oe,m===V||m===me?x.push(c):!c.pure&&i!==null&&i.indexOf(c)===-1&&i.push(c),c.pure&&c.accessor)){let $=O.get(c.accessor);$&&ze(Array.from($),F=>P(F,!0))}}};var G=P;let E=Array.from(R),x=[],g=new Set;ze(E,P);for(let c of x)_n(c)}}}return l.toObservable=()=>new Y(b=>{let v=!0;return we(()=>{let G=l();v?v=!1:b.next(G)})}),Object.defineProperty(l,yn,{value:!0,enumerable:!0}),Object.defineProperty(l,mn,{value:o,enumerable:!1}),r}function we(e,n,t){let o={fn:e,state:oe,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ye(o,n),()=>U(o)}function Ye(e,n){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 t=h,o=f;if(h=e,f=e,re++,re>xn)throw re=0,h=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if(de(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ke(r)}finally{h=t,f=o}}function xe(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===oe||e.state===me||e.state===I)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)U(e.owned[n]);e.owned=null}e.renderEffect?Je(e):Ye(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=O.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)U(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function se(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=O.get(r.accessor);if(s&&s.size>0){let d=h;h=null,r.accessor(),h=d}let l=i.splice(0);for(let d of l)d.pure&&!d.computed&&d.accessor?n.indexOf(d)===-1&&n.push(d):(d.computed||!d.pure)&&t.indexOf(d)===-1&&t.push(d)}i=null;for(let r of t)(r.computed||!r.pure)&&xe(r)}function k(e){if(i&&N>0)return e();if(i&&N===0){let n=i,t=[];i=t,N++;let o;try{o=e()}finally{N--,i=n}let r=i;return se(t),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,An()}}function An(){if(!ye){ye=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,te){let e=te;te=null;for(let n=0;n<e.length;n++)xe(e[n])}}finally{ye=!1}}}function L(e){let n=h;h=null;try{return e()}finally{h=n}}function Xe(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function En(e){let n=Symbol("context"),t=Pn(n);return{id:n,Provider:t,defaultValue:e}}function Pn(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Fn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),$e(()=>n.children)})}),o}}function M(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Fn(e,n,t){let o={fn:e,state:oe,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Je(o),()=>U(o)}function Je(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=h,t=f,o=i;h=e,f=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(de(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ke(r)}finally{h=n,f=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;se(r),i=s}}}var w;function Qe(){return w||(w=En())}var A=new Map,_=new Map,Dn=0,qn=Symbol.for("signal"),Nn=Symbol.for("resource");function In(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:l=1/0,name:d=`_auto_${Dn++}`,staleWhileRevalidate:b=!0}=s,v=d,B=u=>`${v}:${JSON.stringify(u)}`,G=u=>l===1/0||Date.now()-u.timestamp<=l,[R,E]=C(void 0,{equals:!1}),[x,g]=C("unresolved",{equals:!1}),[P,c]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,F]=C(!1),[Ze,ge]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function Se(u,T,y,S){if(_.has(T)){_.get(T).then(p=>{S()||Oe(p,y)},p=>{!S()&&!y&&Re(p)}),y||m(_.get(T));return}let D=Promise.resolve(r(u)).then(p=>(A.set(T,{value:p,timestamp:Date.now()}),_.delete(T),p),p=>{throw _.delete(T),p});if(_.set(T,D),!y){Te(D),m(D);let p=H&&M(H);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{S()||Oe(p,y)},p=>{!S()&&!y&&Re(p)})}function Oe(u,T){k(()=>{E(()=>u),g("ready"),F(!1),m(void 0),c(void 0)})}function Re(u){k(()=>{c(u),g("errored"),m(void 0)})}let H;we(()=>{H===void 0&&(H=Qe());let u=o();if(Ze(),u===!1||u===null||u===void 0){W=ue,k(()=>{g("unresolved"),m(void 0),c(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let S=B(u);y&&A.delete(S);let D=W===ue||u!==W;W=u;let p=!1;Xe(()=>{p=!0});let q=A.get(S);if(q&&G(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&k(()=>{E(()=>q.value),g("ready"),F(!1),c(void 0)});return}if(q&&b&&!y){k(()=>{E(()=>q.value),g("ready"),F(!0),c(void 0),m(void 0)}),Se(u,S,!0,()=>p);return}let Ce=L(x),en=Ce==="ready"||Ce==="refreshing";k(()=>{g(en?"refreshing":"pending"),c(void 0),F(!1)}),Se(u,S,!1,()=>p)});let z=(()=>{let u=P();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(z,Nn,{value:!0,enumerable:!0}),Object.defineProperty(z,qn,{value:!0,enumerable:!0}),Object.defineProperties(z,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:P},latest:{get:R},stale:{get:$}}),[z,{mutate:E,refetch:()=>{ae=!0,ge(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&A.delete(B(u)),le=!0,ge(T=>T+1)}}]}function Un(e){let n=`${e}:`;for(let t of A.keys())t.startsWith(n)&&A.delete(t)}function Ln(){A.clear(),_.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ce(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Re(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(ce(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Re(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(ce(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},de=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new de(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var $e=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?$e:!1,We=Symbol.for("signal");function pe(e){return typeof e=="function"&&e[We]===!0}var ze="__fluixi_signal_next_state__",He=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[ze]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:He,onSuspend:null,onError:null};var Ce=0,_e=1,J=2,he=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 Q=class extends he{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 Pe(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Ee(){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 Ke(e){return!!e&&typeof e.then=="function"}ke(()=>{});var Ye=Symbol.for("signal"),Xe=Symbol.for("memo");function Z(e,t,n){let o=t,r=Ee(),s=new Q(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(Ke(f))return Pe(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:!0,enumerable:!0}),a}function ee(e){if(typeof e=="function"&&!e.length){let t=e();return pe(t)?t:ee(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=ee(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function De(e){let t=Z(e);return X?Z(()=>ee(t()),void 0,{name:"children"}):Z(()=>ee(t()))}var qe=null;function ve(e){qe&&qe(e)}var Je=Symbol.for("signal");var Ne=Symbol("fluixi-proxy"),Qe=Symbol.for("signal-node"),G=0,ye=1,oe=2,I=3,c=null,v=null,i=null,ne=null,re=0,Ze=!1,Te=!1,N=0,et=1e6,O=new WeakMap,te=null;var tt=new Map,nt=0;function rt(){return`node_${++nt}_${Date.now()}`}function ot(e){X&&tt.set(e.id,new WeakRef(e))}function st(e,t,n){let o={id:rt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ot(o),o}function it(e,t){return e===t}function Ue(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function ut(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(te&&te.running&&!e.pure)te.effects.indexOf(e)===-1&&te.effects.push(e);else if(!e.pure||e.computed)me(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;se(o),i=r}}}function Ie(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ne in n&&delete n[Ne];let o=st("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||it;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,ie=!1){let m=l.state;if(!(m===I&&l===v)){if(ie&&!l.pure){m===G&&(l.state=ye,Ze&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=oe,m===G||m===ye?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ie(Array.from($),k=>F(k,!0))}}};var V=F;let E=Array.from(R),x=[],S=new Set;Ie(E,F);for(let l of x)ut(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return be(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Qe,{value:o,enumerable:!1}),r}function be(e,t,n){let o={fn:e,state:oe,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),Le(o,t),()=>U(o)}function Le(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,re++,re>et)throw re=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=n,c=o}}function me(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===oe||e.state===ye||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Be(e):Le(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function se(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)&&me(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 se(n),i=r,o}N++,i=[],ne=[];try{return e()}finally{N--,at()}}function at(){if(!Te){Te=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,ne){let e=ne;ne=null;for(let t=0;t<e.length;t++)me(e[t])}}finally{Te=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Me(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function lt(e){let t=Symbol("context"),n=ct(t);return{id:t,Provider:n,defaultValue:e}}function ct(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 ft(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),De(()=>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 ft(e,t,n){let o={fn:e,state:oe,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),Be(o),()=>U(o)}function Be(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;se(r),i=s}}}var w;function je(){return w||(w=lt())}var P=new Map,A=new Map,dt=0,pt=Symbol.for("signal"),ht=Symbol.for("resource");function cn(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_${dt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,E]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ge,we]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function xe(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||Se(p,y)},p=>{!g()&&!y&&ge(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(P.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){ve(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||Se(p,y)},p=>{!g()&&!y&&ge(p)})}function Se(u,T){_(()=>{E(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function ge(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;be(()=>{z===void 0&&(z=je());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ue,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let g=B(u);y&&P.delete(g);let D=W===ue||u!==W;W=u;let p=!1;Me(()=>{p=!0});let q=P.get(g);if(q&&V(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&_(()=>{E(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{E(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),xe(u,g,!0,()=>p);return}let Oe=L(x),Ve=Oe==="ready"||Oe==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),xe(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(H,ht,{value:!0,enumerable:!0}),Object.defineProperty(H,pt,{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:E,refetch:()=>{ae=!0,we(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&P.delete(B(u)),le=!0,we(T=>T+1)}}]}function fn(e){let t=`${e}:`;for(let n of P.keys())n.startsWith(t)&&P.delete(n)}function dn(){P.clear(),A.clear()}export{dn as clearAllCachedResources,fn as clearCachedResourceNamespace,cn as createCachedResource};
|
|
1
|
+
function ce(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ce(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(ce(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ce(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(ce(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var K=class extends j{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},de=class extends K{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof K?r=n:r=new de(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var en=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?en:!1,nn=Symbol.for("signal");function pe(e){return typeof e=="function"&&e[nn]===!0}var tn="__fluixi_signal_next_state__",rn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[tn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:rn,onSuspend:null,onError:null,observer:null};var ke="1.0.0-alpha.83";function on(e){return a.observer=e,()=>{a.observer===e&&(a.observer=null)}}var ve=[],sn;function Ae(e){let n=a.observer;n&&n.created(e.parents===void 0?{...e,parents:ve,origin:e.origin??sn}:e)}function Ee(e){return a.observer?(ve.push(e),!0):!1}function Pe(){ve.pop()}function Fe(e){a.observer?.ran?.(e)}function De(e){a.observer?.disposed?.(e)}var un="__FLUIXI_DEVTOOLS_HOOK__",_e=globalThis[un];if(typeof _e?.inject=="function")try{_e.inject({observeReactiveNodes:on,version:ke})}catch{}function qe(){return a.observer!=null}var Ne=0,Ie=1,J=2,he=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}};var Q=class extends he{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ie&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ne}recompute(){if(this.sources){for(let v of this.sources)v.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked,r=Ee(this);a.consumer=this,a.untracked=!1;let s,l=!1,d;try{s=this._fn()}catch(v){l=!0,d=v,s=this._value}finally{a.consumer=t,a.untracked=o,r&&Pe()}let b=!this._initialized||this._threw!==l||(l?d!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=l,this._error=d,this._value=s,Fe(this),b){if(this.version++,this.observers)for(let v of[...this.observers])v.markDirty(J);Ue(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Ne;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ie);Ue(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ue(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}function Le(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Me(){return a.owner}function Be(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function je(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Ve(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function an(e){return!!e&&typeof e.then=="function"}Ve(()=>{});var ln=Symbol.for("signal"),cn=Symbol.for("memo");function Z(e,n,t){let o=n,r=Me(),s=new Q(()=>Be(r,()=>{try{return o=e(o)}catch(d){if(an(d))return Le(d),o;throw d}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,ln,{value:!0,enumerable:!0}),Object.defineProperty(l,cn,{value:!0,enumerable:!0}),Ae({kind:"memo",node:s,handle:l,name:t?.name}),qe()&&je(()=>De(s)),l}function ee(e){if(typeof e=="function"&&!e.length){let n=e();return pe(n)?n:ee(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ee(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ge(e){let n=Z(e);return X?Z(()=>ee(n()),void 0,{name:"children"}):Z(()=>ee(n()))}var $e=null;function be(e){$e&&$e(e)}var fn=Symbol.for("signal");var We=Symbol("fluixi-proxy"),dn=Symbol.for("signal-node"),V=0,ye=1,oe=2,I=3,f=null,h=null,i=null,te=null,re=0,pn=!1,Te=!1,N=0,vn=1e6,O=new WeakMap,ne=null;var hn=new Map,bn=0;function Tn(){return`node_${++bn}_${Date.now()}`}function yn(e){X&&hn.set(e.id,new WeakRef(e))}function mn(e,n,t){let o={id:Tn(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return yn(o),o}function wn(e,n){return e===n}function ze(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function xn(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ne&&ne.running&&!e.pure)ne.effects.indexOf(e)===-1&&ne.effects.push(e);else if(!e.pure||e.computed)we(e);else if(e.pure&&!e.computed&&e.accessor){let n=h,t=i;h=null,i=[],e.accessor(),h=n;let o=i;if(i=t,o.length>0){let r=i;se(o),i=r}}}function He(e,n){for(let t=0;t<e.length;t++)n(e[t])}function C(e,n){let t=e;typeof t=="object"&&t&&We in t&&delete t[We];let o=mn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,d];O.set(r,new Set);let s;function l(){let b=h;if(b){b.sources?b.sources.indexOf(r)===-1&&b.sources.push(r):b.sources=[r];let v=O.get(r);v&&!v.has(b)&&v.add(b)}return t}function d(b){let v=typeof b=="function"?b(t):b,B=o.equals||wn;if(n?.equals===!1||!B(t,v)){t=v,o.value=v,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let P=function(c,ie=!1){let m=c.state;if(!(m===I&&c===h)){if(ie&&!c.pure){m===V&&(c.state=ye,pn&&(i!==null&&i.indexOf(c)===-1?i.push(c):x.push(c)));return}if(!g.has(c)&&(g.add(c),c.state=oe,m===V||m===ye?x.push(c):!c.pure&&i!==null&&i.indexOf(c)===-1&&i.push(c),c.pure&&c.accessor)){let $=O.get(c.accessor);$&&He(Array.from($),F=>P(F,!0))}}};var G=P;let E=Array.from(R),x=[],g=new Set;He(E,P);for(let c of x)xn(c)}}}return l.toObservable=()=>new Y(b=>{let v=!0;return me(()=>{let G=l();v?v=!1:b.next(G)})}),Object.defineProperty(l,fn,{value:!0,enumerable:!0}),Object.defineProperty(l,dn,{value:o,enumerable:!1}),r}function me(e,n,t){let o={fn:e,state:oe,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ke(o,n),()=>U(o)}function Ke(e,n){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 t=h,o=f;if(h=e,f=e,re++,re>vn)throw re=0,h=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}ze(r)}finally{h=t,f=o}}function we(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===oe||e.state===ye||e.state===I)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)U(e.owned[n]);e.owned=null}e.renderEffect?Xe(e):Ke(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=O.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)U(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function se(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=O.get(r.accessor);if(s&&s.size>0){let d=h;h=null,r.accessor(),h=d}let l=i.splice(0);for(let d of l)d.pure&&!d.computed&&d.accessor?n.indexOf(d)===-1&&n.push(d):(d.computed||!d.pure)&&t.indexOf(d)===-1&&t.push(d)}i=null;for(let r of t)(r.computed||!r.pure)&&we(r)}function k(e){if(i&&N>0)return e();if(i&&N===0){let n=i,t=[];i=t,N++;let o;try{o=e()}finally{N--,i=n}let r=i;return se(t),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,gn()}}function gn(){if(!Te){Te=!0,re=0;try{for(;i&&i.length>0;){let e=i;i=null,se(e)}if(i=null,te){let e=te;te=null;for(let n=0;n<e.length;n++)we(e[n])}}finally{Te=!1}}}function L(e){let n=h;h=null;try{return e()}finally{h=n}}function Ye(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function Sn(e){let n=Symbol("context"),t=On(n);return{id:n,Provider:t,defaultValue:e}}function On(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Rn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ge(()=>n.children)})}),o}}function M(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Rn(e,n,t){let o={fn:e,state:oe,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Xe(o),()=>U(o)}function Xe(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 n=h,t=f,o=i;h=e,f=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(fe(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}ze(r)}finally{h=n,f=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;se(r),i=s}}}var w;function Je(){return w||(w=Sn())}var A=new Map,_=new Map,Cn=0,kn=Symbol.for("signal"),_n=Symbol.for("resource");function Et(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:l=1/0,name:d=`_auto_${Cn++}`,staleWhileRevalidate:b=!0}=s,v=d,B=u=>`${v}:${JSON.stringify(u)}`,G=u=>l===1/0||Date.now()-u.timestamp<=l,[R,E]=C(void 0,{equals:!1}),[x,g]=C("unresolved",{equals:!1}),[P,c]=C(void 0,{equals:!1}),[ie,m]=C(void 0,{equals:!1}),[$,F]=C(!1),[Qe,xe]=C(0,{equals:!1}),ue=Symbol("unset"),W=ue,ae=!1,le=!1;function ge(u,T,y,S){if(_.has(T)){_.get(T).then(p=>{S()||Se(p,y)},p=>{!S()&&!y&&Oe(p)}),y||m(_.get(T));return}let D=Promise.resolve(r(u)).then(p=>(A.set(T,{value:p,timestamp:Date.now()}),_.delete(T),p),p=>{throw _.delete(T),p});if(_.set(T,D),!y){be(D),m(D);let p=H&&M(H);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{S()||Se(p,y)},p=>{!S()&&!y&&Oe(p)})}function Se(u,T){k(()=>{E(()=>u),g("ready"),F(!1),m(void 0),c(void 0)})}function Oe(u){k(()=>{c(u),g("errored"),m(void 0)})}let H;me(()=>{H===void 0&&(H=Je());let u=o();if(Qe(),u===!1||u===null||u===void 0){W=ue,k(()=>{g("unresolved"),m(void 0),c(void 0)});return}let T=ae,y=le;ae=!1,le=!1;let S=B(u);y&&A.delete(S);let D=W===ue||u!==W;W=u;let p=!1;Ye(()=>{p=!0});let q=A.get(S);if(q&&G(q)&&!T&&!y){(L(x)!=="ready"||L(R)!==q.value)&&k(()=>{E(()=>q.value),g("ready"),F(!1),c(void 0)});return}if(q&&b&&!y){k(()=>{E(()=>q.value),g("ready"),F(!0),c(void 0),m(void 0)}),ge(u,S,!0,()=>p);return}let Re=L(x),Ze=Re==="ready"||Re==="refreshing";k(()=>{g(Ze?"refreshing":"pending"),c(void 0),F(!1)}),ge(u,S,!1,()=>p)});let z=(()=>{let u=P();if(u)throw u;if(x()==="pending"){let y=ie();if(y)throw y}return R()});return Object.defineProperty(z,_n,{value:!0,enumerable:!0}),Object.defineProperty(z,kn,{value:!0,enumerable:!0}),Object.defineProperties(z,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:P},latest:{get:R},stale:{get:$}}),[z,{mutate:E,refetch:()=>{ae=!0,xe(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&A.delete(B(u)),le=!0,xe(T=>T+1)}}]}function Pt(e){let n=`${e}:`;for(let t of A.keys())t.startsWith(n)&&A.delete(t)}function Ft(){A.clear(),_.clear()}export{Ft as clearAllCachedResources,Pt as clearCachedResourceNamespace,Et as createCachedResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var j=(e,n)=>{for(var r in n)v(e,r,{get:n[r],enumerable:!0})},G=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of V(n))!W.call(e,i)&&i!==r&&v(e,i,{get:()=>n[i],enumerable:!(o=M(n,i))||o.enumerable});return e};var H=e=>G(v({},"__esModule",{value:!0}),e);var Z={};j(Z,{readChildren:()=>Q});module.exports=H(Z);var z="__fluixi_signal_next_state__",F=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},t=globalThis[z]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:F,onSuspend:null,onError:null,observer:null};var y="1.0.0-alpha.83";function K(e){return t.observer=e,()=>{t.observer===e&&(t.observer=null)}}var h=[],L;function T(e){let n=t.observer;n&&n.created(e.parents===void 0?{...e,parents:h,origin:e.origin??L}:e)}function m(e){return t.observer?(h.push(e),!0):!1}function x(){h.pop()}function k(e){t.observer?.ran?.(e)}function g(e){t.observer?.disposed?.(e)}var $="__FLUIXI_DEVTOOLS_HOOK__",b=globalThis[$];if(typeof b?.inject=="function")try{b.inject({observeReactiveNodes:K,version:y})}catch{}function _(){return t.observer!=null}var R=0,S=1,l=2,w=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(t.untracked)return;let n=t.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}};var d=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(t.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===S&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=R}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=t.consumer,o=t.untracked,i=m(this);t.consumer=this,t.untracked=!1;let u,s=!1,a;try{u=this._fn()}catch(c){s=!0,a=c,u=this._value}finally{t.consumer=r,t.untracked=o,i&&x()}let I=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,u));if(this._initialized=!0,this._threw=s,this._error=a,this._value=u,k(this),I){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);O(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===R;if(this.state=r,o){if(this.observers)for(let i of[...this.observers])i.markDirty(S);O(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function O(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}function C(e){return t.onSuspend?(t.onSuspend(e,t.owner),!0):!1}function D(){return t.owner}function A(e,n){let r=t.owner;t.owner=e;try{return n()}finally{t.owner=r}}function q(e){if(t.owner){if(t.owner.disposed){e();return}(t.owner.cleanups??=[]).push(e)}}function E(e){t.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function U(e){return!!e&&typeof e.then=="function"}E(()=>{});var Y=Symbol.for("signal"),B=Symbol.for("memo");function f(e,n,r){let o=n,i=D(),u=new d(()=>A(i,()=>{try{return o=e(o)}catch(a){if(U(a))return C(a),o;throw a}}),{equals:r?.equals}),s=(()=>u.get());return Object.defineProperty(s,Y,{value:!0,enumerable:!0}),Object.defineProperty(s,B,{value:!0,enumerable:!0}),T({kind:"memo",node:u,handle:s,name:r?.name}),_()&&q(()=>g(u)),s}var X=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,N=typeof process>"u"?X:!1,J=Symbol.for("signal");function P(e){return typeof e=="function"&&e[J]===!0}function p(e){if(typeof e=="function"&&!e.length){let n=e();return P(n)?n:p(n)}if(Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++){let o=p(e[r]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Q(e){let n=f(e);return N?f(()=>p(n()),void 0,{name:"children"}):f(()=>p(n()))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I="__fluixi_signal_next_state__",M=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[I]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:M,onSuspend:null,onError:null,observer:null};var w="1.0.0-alpha.83";function V(e){return n.observer=e,()=>{n.observer===e&&(n.observer=null)}}var v=[],W;function b(e){let t=n.observer;t&&t.created(e.parents===void 0?{...e,parents:v,origin:e.origin??W}:e)}function T(e){return n.observer?(v.push(e),!0):!1}function m(){v.pop()}function x(e){n.observer?.ran?.(e)}function k(e){n.observer?.disposed?.(e)}var j="__FLUIXI_DEVTOOLS_HOOK__",y=globalThis[j];if(typeof y?.inject=="function")try{y.inject({observeReactiveNodes:V,version:w})}catch{}function g(){return n.observer!=null}var _=0,R=1,l=2,h=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 d=class extends h{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===R&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===l)break}(this.state===l||!this._initialized)&&this.recompute(),this.state=_}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked,a=T(this);n.consumer=this,n.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(c){i=!0,u=c,s=this._value}finally{n.consumer=r,n.untracked=o,a&&m()}let P=!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,x(this),P){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(l);S(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===_;if(this.state=r,o){if(this.observers)for(let a of[...this.observers])a.markDirty(R);S(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function S(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function O(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function C(){return n.owner}function D(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function A(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function q(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function G(e){return!!e&&typeof e.then=="function"}q(()=>{});var H=Symbol.for("signal"),z=Symbol.for("memo");function f(e,t,r){let o=t,a=C(),s=new d(()=>D(a,()=>{try{return o=e(o)}catch(u){if(G(u))return O(u),o;throw u}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,H,{value:!0,enumerable:!0}),Object.defineProperty(i,z,{value:!0,enumerable:!0}),b({kind:"memo",node:s,handle:i,name:r?.name}),g()&&A(()=>k(s)),i}var F=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,E=typeof process>"u"?F:!1,K=Symbol.for("signal");function N(e){return typeof e=="function"&&e[K]===!0}function p(e){if(typeof e=="function"&&!e.length){let t=e();return N(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 he(e){let t=f(e);return E?f(()=>p(t()),void 0,{name:"children"}):f(()=>p(t()))}export{he as readChildren};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var X=(e,n)=>{for(var t in n)R(e,t,{get:n[t],enumerable:!0})},J=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of U(n))!B.call(e,i)&&i!==t&&R(e,i,{get:()=>n[i],enumerable:!(o=$(n,i))||o.enumerable});return e};var Q=e=>J(R({},"__esModule",{value:!0}),e);var Te={};X(Te,{batch:()=>pe,createComputed:()=>de,createEffect:()=>le,createMemo:()=>ce,createRenderEffect:()=>fe,createRoot:()=>z,createSignal:()=>ae,flush:()=>we,flushSync:()=>d,getOwner:()=>y,on:()=>be,onCleanup:()=>w,runWithOwner:()=>h,setOwner:()=>H,startTransition:()=>Y,untrack:()=>ve,useTransition:()=>he});module.exports=Q(Te);var Z="__fluixi_signal_next_state__",ee=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[Z]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ee,onSuspend:null,onError:null,observer:null};var N="1.0.0-alpha.83";function ne(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var O=[],te;function f(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:O,origin:e.origin??te}:e)}function E(e){return r.observer?(O.push(e),!0):!1}function A(){O.pop()}function I(e){r.observer?.ran?.(e)}function M(e,n){r.observer?.wrote?.(e,n)}function p(e){r.observer?.disposed?.(e)}var re="__FLUIXI_DEVTOOLS_HOOK__",P=globalThis[re];if(typeof P?.inject=="function")try{P.inject({observeReactiveNodes:ne,version:N})}catch{}function _(){return r.observer!=null}var W=0,j=1,v=2,b=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},T=class extends b{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++,M(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(v);S(this)}}peek(){return this._value}},l=class extends b{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,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===j&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!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 t=r.consumer,o=r.untracked,i=E(this);r.consumer=this,r.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(c){u=!0,a=c,s=this._value}finally{r.consumer=t,r.untracked=o,i&&A()}let g=!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,I(this),g){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(v);S(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===W;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(j);S(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function S(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var m=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 C(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function V(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function y(){return r.owner}function H(e){let n=r.owner;return r.owner=e,n}function h(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function w(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function k(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)k(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 z(e){let n=V(r.owner);r.owner&&(r.owner.owned??=[]).push(n);let t=r.owner;r.owner=n;try{return e(()=>k(n))}finally{r.owner=t}}function K(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function oe(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 n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function F(){r.batchDepth===0&&d()}function D(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&d()}}var q=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=V(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{k(this.owner,!1),h(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),f({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new m(()=>oe(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"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,p(this.computed),this.watcher.unwatch(this.computed),k(this.owner))}};function x(e,n=!1){let t=new q(e,n);return()=>t.dispose()}function ie(e){return!!e&&typeof e.then=="function"}K(()=>{});var L=Symbol.for("signal"),se=Symbol.for("memo"),ue=Symbol.for("signal-node");function ae(e,n){let t=new T(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),F(),u});return Object.defineProperty(o,L,{value:!0,enumerable:!0}),Object.defineProperty(o,ue,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),f({kind:"signal",node:t,handle:o,name:n?.name,set:i}),_()&&w(()=>p(t)),[o,i]}function ce(e,n,t){let o=n,i=y(),s=new l(()=>h(i,()=>{try{return o=e(o)}catch(a){if(ie(a))return G(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,L,{value:!0,enumerable:!0}),Object.defineProperty(u,se,{value:!0,enumerable:!0}),f({kind:"memo",node:s,handle:u,name:t?.name}),_()&&w(()=>p(s)),u}function le(e,n){let t=n;return x(()=>{t=e(t)},!0)}function de(e,n){let t=n;x(()=>{t=e(t)})}function fe(e,n){let t=n;return x(()=>{t=e(t)})}function pe(e){return D(e)}function ve(e){return C(e)}function Y(e){return D(e),Promise.resolve()}function he(){return[()=>!1,Y]}function we(){return d(),Promise.resolve()}function be(e,n,t){let o=Array.isArray(e),i,s=t?.defer??!1;return u=>{let a=o?e.map(c=>c()):e();if(s){s=!1,i=a;return}let g=C(()=>n(a,i,u));return i=a,g}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/compat.ts"],"names":[],"mappings":"AAgBA,OAAO,EAKL,SAAS,
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/compat.ts"],"names":[],"mappings":"AAgBA,OAAO,EAKL,SAAS,EAKV,MAAM,cAAc,CAAC;AAOtB,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,CAkC/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,CAoCb;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"}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* install a synchronous L1 scheduler here; `batch` still coalesces to one flush.
|
|
15
15
|
*/
|
|
16
16
|
import { State, Computed, untrack as l0untrack } from './core.js';
|
|
17
|
-
import { effect as l1effect, batch as l1batch, setScheduler, afterWrite, flushSync, reportSuspend, getOwner, runWithOwner, } from './runtime.js';
|
|
17
|
+
import { effect as l1effect, batch as l1batch, setScheduler, afterWrite, flushSync, reportSuspend, getOwner, runWithOwner, onCleanup as l1onCleanup, } from './runtime.js';
|
|
18
|
+
import { isObserved, reportReactiveDispose, reportReactiveNode } from './observe.js';
|
|
18
19
|
function isThenable(v) {
|
|
19
20
|
return !!v && typeof v.then === 'function';
|
|
20
21
|
}
|
|
@@ -54,6 +55,17 @@ export function createSignal(value, options) {
|
|
|
54
55
|
},
|
|
55
56
|
enumerable: false,
|
|
56
57
|
});
|
|
58
|
+
reportReactiveNode({
|
|
59
|
+
kind: 'signal',
|
|
60
|
+
node: state,
|
|
61
|
+
handle: read,
|
|
62
|
+
name: options?.name,
|
|
63
|
+
set: write,
|
|
64
|
+
});
|
|
65
|
+
// A signal goes when its owner does, the same as a memo. A list rebuilt without a key
|
|
66
|
+
// makes one per row per update, and a watcher that is never told keeps every one of them.
|
|
67
|
+
if (isObserved())
|
|
68
|
+
l1onCleanup(() => reportReactiveDispose(state));
|
|
57
69
|
return [read, write];
|
|
58
70
|
}
|
|
59
71
|
/** createMemo — a lazy, cached derived value (legacy accessor). */
|
|
@@ -85,6 +97,11 @@ export function createMemo(fn, value, options) {
|
|
|
85
97
|
// as reactive, caches it as a component, and freezes it → updates never apply.
|
|
86
98
|
Object.defineProperty(read, $SIGNAL, { value: true, enumerable: true });
|
|
87
99
|
Object.defineProperty(read, $MEMO, { value: true, enumerable: true });
|
|
100
|
+
reportReactiveNode({ kind: 'memo', node: c, handle: read, name: options?.name });
|
|
101
|
+
// A memo has no dispose of its own — it goes when its owner does. Without saying so, a
|
|
102
|
+
// list that re-renders leaves every row it ever had in a watcher's graph.
|
|
103
|
+
if (isObserved())
|
|
104
|
+
l1onCleanup(() => reportReactiveDispose(c));
|
|
88
105
|
return read;
|
|
89
106
|
}
|
|
90
107
|
/**
|
|
@@ -99,7 +116,7 @@ export function createEffect(fn, value) {
|
|
|
99
116
|
// never returns one, in which case onCleanup is the cleanup path. We keep the
|
|
100
117
|
// legacy carry-the-value behaviour; cleanups use onCleanup.
|
|
101
118
|
prev = r;
|
|
102
|
-
});
|
|
119
|
+
}, true);
|
|
103
120
|
}
|
|
104
121
|
/**
|
|
105
122
|
* createComputed — an EAGER, owner-managed reactive computation (returns void).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K="__fluixi_signal_next_state__",F=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[K]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:F,onSuspend:null,onError:null,observer:null};var D="1.0.0-alpha.83";function L(e){return n.observer=e,()=>{n.observer===e&&(n.observer=null)}}var g=[],Y;function d(e){let t=n.observer;t&&t.created(e.parents===void 0?{...e,parents:g,origin:e.origin??Y}:e)}function P(e){return n.observer?(g.push(e),!0):!1}function E(){g.pop()}function A(e){n.observer?.ran?.(e)}function I(e,t){n.observer?.wrote?.(e,t)}function f(e){n.observer?.disposed?.(e)}var $="__FLUIXI_DEVTOOLS_HOOK__",N=globalThis[$];if(typeof N?.inject=="function")try{N.inject({observeReactiveNodes:L,version:D})}catch{}function R(){return n.observer!=null}var M=0,W=1,p=2,h=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))}},w=class extends h{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,I(this,n.consumer),this.observers)for(let r of[...this.observers])r.markDirty(p);O(this)}}peek(){return this._value}},l=class extends h{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=p;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===W&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===p)break}(this.state===p||!this._initialized)&&this.recompute(),this.state=M}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked,u=P(this);n.consumer=this,n.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(c){s=!0,a=c,i=this._value}finally{n.consumer=r,n.untracked=o,u&&E()}let x=!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,A(this),x){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(p);O(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===M;if(this.state=r,o){if(this.observers)for(let u of[...this.observers])u.markDirty(W);O(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function O(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var b=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function _(e){if(n.untracked)return e();n.untracked=!0;try{return e()}finally{n.untracked=!1}}function j(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function C(){return n.owner}function U(e){let t=n.owner;return n.owner=e,t}function m(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function k(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function T(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)T(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function B(e){let t=j(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>T(t))}finally{n.owner=r}}function G(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function X(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(v)))}function v(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=n.queue;n.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{n.flushing=!1}}function H(){n.batchDepth===0&&v()}function q(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&v()}}var S=class{constructor(t,r=!1){this.queued=!1;this.disposed=!1;this.owner=j(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new l(()=>{T(this.owner,!1),m(this.owner,()=>{let o=t();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),d({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new b(()=>X(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"&&n.onSuspend){n.onSuspend(t,this.owner);return}if(n.onError&&n.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,f(this.computed),this.watcher.unwatch(this.computed),T(this.owner))}};function y(e,t=!1){let r=new S(e,t);return()=>r.dispose()}function J(e){return!!e&&typeof e.then=="function"}G(()=>{});var z=Symbol.for("signal"),Q=Symbol.for("memo"),Z=Symbol.for("signal-node");function Te(e,t){let r=new w(e,{equals:t?.equals}),o=(()=>r.get()),u=(i=>{let s=typeof i=="function"?i(r.peek()):i;return r.set(s),H(),s});return Object.defineProperty(o,z,{value:!0,enumerable:!0}),Object.defineProperty(o,Z,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),d({kind:"signal",node:r,handle:o,name:t?.name,set:u}),R()&&k(()=>f(r)),[o,u]}function me(e,t,r){let o=t,u=C(),i=new l(()=>m(u,()=>{try{return o=e(o)}catch(a){if(J(a))return V(a),o;throw a}}),{equals:r?.equals}),s=(()=>i.get());return Object.defineProperty(s,z,{value:!0,enumerable:!0}),Object.defineProperty(s,Q,{value:!0,enumerable:!0}),d({kind:"memo",node:i,handle:s,name:r?.name}),R()&&k(()=>f(i)),s}function ke(e,t){let r=t;return y(()=>{r=e(r)},!0)}function ye(e,t){let r=t;y(()=>{r=e(r)})}function xe(e,t){let r=t;return y(()=>{r=e(r)})}function ge(e){return q(e)}function Re(e){return _(e)}function ee(e){return q(e),Promise.resolve()}function Oe(){return[()=>!1,ee]}function _e(){return v(),Promise.resolve()}function Se(e,t,r){let o=Array.isArray(e),u,i=r?.defer??!1;return s=>{let a=o?e.map(c=>c()):e();if(i){i=!1,u=a;return}let x=_(()=>t(a,u,s));return u=a,x}}export{ge as batch,ye as createComputed,ke as createEffect,me as createMemo,xe as createRenderEffect,B as createRoot,Te as createSignal,_e as flush,v as flushSync,C as getOwner,Se as on,k as onCleanup,m as runWithOwner,U as setOwner,ee as startTransition,Re as untrack,Oe as useTransition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},D=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!q.call(e,s)&&s!==n&&d(e,s,{get:()=>t[s],enumerable:!(o=O(t,s))||o.enumerable});return e};var E=e=>D(d({},"__esModule",{value:!0}),e);var L={};C(L,{Computed:()=>f,State:()=>h,Watcher:()=>b,currentComputed:()=>j,hasSinks:()=>F,untrack:()=>H});module.exports=E(L);var I="__fluixi_signal_next_state__",z=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[I]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:z,onSuspend:null,onError:null,observer:null};var w="1.0.0-alpha.83";function K(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var _=[];function R(e){return r.observer?(_.push(e),!0):!1}function g(){_.pop()}function y(e){r.observer?.ran?.(e)}function m(e,t){r.observer?.wrote?.(e,t)}var G="__FLUIXI_DEVTOOLS_HOOK__",k=globalThis[G];if(typeof k?.inject=="function")try{k.inject({observeReactiveNodes:K,version:w})}catch{}var x=0,T=1,a=2,v=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))}},h=class extends v{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++,m(this,r.consumer),this.observers)for(let n of[...this.observers])n.markDirty(a);p(this)}}peek(){return this._value}},f=class extends v{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=a;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===T&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===a)break}(this.state===a||!this._initialized)&&this.recompute(),this.state=x}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked,s=R(this);r.consumer=this,r.untracked=!1;let u,c=!1,l;try{u=this._fn()}catch(i){c=!0,l=i,u=this._value}finally{r.consumer=n,r.untracked=o,s&&g()}let S=!this._initialized||this._threw!==c||(c?l!==this._error:!this._equals(this._value,u));if(this._initialized=!0,this._threw=c,this._error=l,this._value=u,y(this),S){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(a);p(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===x;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(T);p(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function p(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var b=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 H(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function j(){return r.consumer}function F(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,QAAA,MAAM,KAAK,IAAI,CAAC;AAChB,QAAA,MAAM,KAAK,IAAI,CAAC;AAChB,QAAA,MAAM,KAAK,IAAI,CAAC;AAChB,KAAK,SAAS,GAAG,OAAO,KAAK,GAAG,OAAO,KAAK,GAAG,OAAO,KAAK,CAAC;AAK5D,gFAAgF;AAChF,uBAAe,MAAM;IACnB,0FAA0F;IAE1F,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAQ;IAC5C,wEAAwE;IACxE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAQ;IACrC,2EAA2E;IAC3E,OAAO,SAAK;IAEZ,yFAAyF;IACzF,iBAAiB,IAAI,IAAI;IAEzB,sEAAsE;IACtE,SAAS,CAAC,KAAK,IAAI,IAAI;CAOxB;AAED,qBAAa,KAAK,CAAC,CAAC,CAAE,SAAQ,MAAM;IAClC,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,KAAK,CAAA;KAAE;IAM9E,GAAG,IAAI,CAAC;IAKR,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAclB,uCAAuC;IACvC,IAAI,IAAI,CAAC;CAGV;AAED,qBAAa,QAAQ,CAAC,CAAC,CAAE,SAAQ,MAAM;IACrC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,KAAK,EAAE,SAAS,CAAS;IACzB,6EAA6E;IAC7E,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,KAAK,CAAA;KAAE;IAMjF,GAAG,IAAI,CAAC;IAWR,4EAA4E;IACnE,iBAAiB,IAAI,IAAI;IAelC,OAAO,CAAC,SAAS;IA8CjB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAUjC,IAAI,IAAI,CAAC;CAKV;AAOD;;;;GAIG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAqB;gBAEzB,MAAM,EAAE,MAAM,IAAI;IAI9B,KAAK,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAO/B,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAQjC,uEAAuE;IACvE,UAAU,IAAI,MAAM,EAAE;IAMtB,gFAAgF;IAChF,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAM5B;AAED,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQzC;AAED,kFAAkF;AAClF,wBAAgB,eAAe,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAE1D;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C"}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* actually changed (equality-gated). Reads outside a tracking scope don't subscribe.
|
|
17
17
|
*/
|
|
18
18
|
import { G } from './state.js';
|
|
19
|
+
import { enterReactiveRun, exitReactiveRun, reportReactiveRun, reportReactiveWrite } from './observe.js';
|
|
19
20
|
// Node states. CHECK = "a source may have changed — verify on read" (your STALE);
|
|
20
21
|
// DIRTY = "definitely recompute"; CLEAN = "cached value is current".
|
|
21
22
|
const CLEAN = 0;
|
|
@@ -62,6 +63,8 @@ export class State extends Source {
|
|
|
62
63
|
return;
|
|
63
64
|
this._value = next;
|
|
64
65
|
this.version++;
|
|
66
|
+
// Who wrote it: once a write has propagated, nothing else records what caused it.
|
|
67
|
+
reportReactiveWrite(this, G.consumer);
|
|
65
68
|
// Push: direct observers are DIRTY, their transitive observers are CHECK.
|
|
66
69
|
// Snapshot first — a synchronous scheduler can re-run an effect mid-propagation,
|
|
67
70
|
// which re-subscribes (mutates `observers`); iterating the live Set would then
|
|
@@ -128,6 +131,7 @@ export class Computed extends Source {
|
|
|
128
131
|
}
|
|
129
132
|
const prevConsumer = G.consumer;
|
|
130
133
|
const prevUntracked = G.untracked;
|
|
134
|
+
const watched = enterReactiveRun(this);
|
|
131
135
|
G.consumer = this;
|
|
132
136
|
G.untracked = false;
|
|
133
137
|
let next;
|
|
@@ -144,6 +148,8 @@ export class Computed extends Source {
|
|
|
144
148
|
finally {
|
|
145
149
|
G.consumer = prevConsumer;
|
|
146
150
|
G.untracked = prevUntracked;
|
|
151
|
+
if (watched)
|
|
152
|
+
exitReactiveRun();
|
|
147
153
|
}
|
|
148
154
|
const changed = !this._initialized ||
|
|
149
155
|
this._threw !== threw ||
|
|
@@ -152,6 +158,7 @@ export class Computed extends Source {
|
|
|
152
158
|
this._threw = threw;
|
|
153
159
|
this._error = err;
|
|
154
160
|
this._value = next;
|
|
161
|
+
reportReactiveRun(this);
|
|
155
162
|
if (changed) {
|
|
156
163
|
this.version++;
|
|
157
164
|
// Our value moved → observers that were merely CHECK must now recompute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S="__fluixi_signal_next_state__",O=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[S]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:O,onSuspend:null,onError:null,observer:null};var h="1.0.0-alpha.83";function N(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var p=[];function b(e){return r.observer?(p.push(e),!0):!1}function w(){p.pop()}function k(e){r.observer?.ran?.(e)}function _(e,t){r.observer?.wrote?.(e,t)}var q="__FLUIXI_DEVTOOLS_HOOK__",f=globalThis[q];if(typeof f?.inject=="function")try{f.inject({observeReactiveNodes:N,version:h})}catch{}var R=0,g=1,i=2,c=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))}},y=class extends c{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,r.consumer),this.observers)for(let n of[...this.observers])n.markDirty(i);d(this)}}peek(){return this._value}},m=class extends c{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=i;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===g&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===i)break}(this.state===i||!this._initialized)&&this.recompute(),this.state=R}recompute(){if(this.sources){for(let s of this.sources)s.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked,v=b(this);r.consumer=this,r.untracked=!1;let a,u=!1,l;try{a=this._fn()}catch(s){u=!0,l=s,a=this._value}finally{r.consumer=n,r.untracked=o,v&&w()}let T=!this._initialized||this._threw!==u||(u?l!==this._error:!this._equals(this._value,a));if(this._initialized=!0,this._threw=u,this._error=l,this._value=a,k(this),T){if(this.version++,this.observers)for(let s of[...this.observers])s.markDirty(i);d(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===R;if(this.state=n,o){if(this.observers)for(let v of[...this.observers])v.markDirty(g);d(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function d(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var x=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 H(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function j(){return r.consumer}function F(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}export{m as Computed,y as State,x as Watcher,j as currentComputed,F as hasSinks,H as untrack};
|