@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.
Files changed (84) hide show
  1. package/README.md +4 -0
  2. package/dist/cdn/reactive.cjs +1 -1
  3. package/dist/cdn/reactive.global.js +1 -1
  4. package/dist/cdn/reactive.mjs +1 -1
  5. package/dist/cdn/signal.cjs +1 -1
  6. package/dist/cdn/signal.global.js +1 -1
  7. package/dist/cdn/signal.mjs +1 -1
  8. package/dist/index.cjs +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/lib/index.cjs +1 -1
  11. package/dist/lib/index.mjs +1 -1
  12. package/dist/lib/signal/api.cjs +1 -1
  13. package/dist/lib/signal/api.mjs +1 -1
  14. package/dist/lib/signal/cached-resource.cjs +1 -1
  15. package/dist/lib/signal/cached-resource.mjs +1 -1
  16. package/dist/lib/signal/graph/children.cjs +1 -1
  17. package/dist/lib/signal/graph/children.mjs +1 -1
  18. package/dist/lib/signal/graph/compat.cjs +1 -1
  19. package/dist/lib/signal/graph/compat.d.ts.map +1 -1
  20. package/dist/lib/signal/graph/compat.js +19 -2
  21. package/dist/lib/signal/graph/compat.mjs +1 -1
  22. package/dist/lib/signal/graph/core.cjs +1 -1
  23. package/dist/lib/signal/graph/core.d.ts.map +1 -1
  24. package/dist/lib/signal/graph/core.js +7 -0
  25. package/dist/lib/signal/graph/core.mjs +1 -1
  26. package/dist/lib/signal/graph/debounced.cjs +1 -1
  27. package/dist/lib/signal/graph/debounced.mjs +1 -1
  28. package/dist/lib/signal/graph/derived.cjs +1 -1
  29. package/dist/lib/signal/graph/derived.mjs +1 -1
  30. package/dist/lib/signal/graph/error-boundary.cjs +1 -1
  31. package/dist/lib/signal/graph/error-boundary.mjs +1 -1
  32. package/dist/lib/signal/graph/index.cjs +1 -1
  33. package/dist/lib/signal/graph/index.mjs +1 -1
  34. package/dist/lib/signal/graph/observe.cjs +1 -0
  35. package/dist/lib/signal/graph/observe.d.ts +141 -0
  36. package/dist/lib/signal/graph/observe.d.ts.map +1 -0
  37. package/dist/lib/signal/graph/observe.js +149 -0
  38. package/dist/lib/signal/graph/observe.mjs +1 -0
  39. package/dist/lib/signal/graph/resource.cjs +1 -1
  40. package/dist/lib/signal/graph/resource.mjs +1 -1
  41. package/dist/lib/signal/graph/runtime.cjs +1 -1
  42. package/dist/lib/signal/graph/runtime.d.ts +2 -2
  43. package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
  44. package/dist/lib/signal/graph/runtime.js +22 -7
  45. package/dist/lib/signal/graph/runtime.mjs +1 -1
  46. package/dist/lib/signal/graph/signal-next.cjs +1 -1
  47. package/dist/lib/signal/graph/signal-next.mjs +1 -1
  48. package/dist/lib/signal/graph/state.cjs +1 -1
  49. package/dist/lib/signal/graph/state.d.ts +2 -0
  50. package/dist/lib/signal/graph/state.d.ts.map +1 -1
  51. package/dist/lib/signal/graph/state.js +1 -0
  52. package/dist/lib/signal/graph/state.mjs +1 -1
  53. package/dist/lib/signal/graph/suspense.cjs +1 -1
  54. package/dist/lib/signal/graph/suspense.mjs +1 -1
  55. package/dist/lib/signal/index-legacy.cjs +1 -1
  56. package/dist/lib/signal/index-legacy.mjs +1 -1
  57. package/dist/lib/signal/index.cjs +1 -1
  58. package/dist/lib/signal/index.d.ts +2 -0
  59. package/dist/lib/signal/index.d.ts.map +1 -1
  60. package/dist/lib/signal/index.js +2 -0
  61. package/dist/lib/signal/index.mjs +1 -1
  62. package/dist/lib/signal/list.cjs +1 -1
  63. package/dist/lib/signal/list.js +5 -5
  64. package/dist/lib/signal/list.mjs +1 -1
  65. package/dist/lib/signal/resource-api.cjs +1 -1
  66. package/dist/lib/signal/resource-api.mjs +1 -1
  67. package/dist/lib/signal/signal.cjs +1 -1
  68. package/dist/lib/signal/signal.mjs +1 -1
  69. package/dist/lib/signal/utilities.cjs +1 -1
  70. package/dist/lib/signal/utilities.mjs +1 -1
  71. package/dist/lib/store/api.cjs +1 -1
  72. package/dist/lib/store/api.mjs +1 -1
  73. package/dist/lib/store/index.cjs +1 -1
  74. package/dist/lib/store/index.mjs +1 -1
  75. package/dist/lib/store/store.cjs +1 -1
  76. package/dist/lib/store/store.d.ts.map +1 -1
  77. package/dist/lib/store/store.js +148 -8
  78. package/dist/lib/store/store.mjs +1 -1
  79. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  80. package/dist/version.generated.cjs +1 -1
  81. package/dist/version.generated.d.ts +1 -1
  82. package/dist/version.generated.js +1 -1
  83. package/dist/version.generated.mjs +1 -1
  84. package/package.json +2 -2
@@ -0,0 +1,149 @@
1
+ /**
2
+ * A place for a tool to watch the reactive graph from outside it.
3
+ *
4
+ * The runtime says a node exists, a computation re-ran, or an effect went away, and hands
5
+ * over the node itself. It does nothing else. Edges are already on the node — a source keeps
6
+ * its `observers`, a consumer keeps its `sources` — so a watcher reads the graph rather than
7
+ * reconstructing it, and nothing here wraps or replaces a primitive.
8
+ *
9
+ * Nothing is registered by default: an unwatched runtime pays one null check per node
10
+ * creation and per recompute.
11
+ *
12
+ * @fluixi/devtools is the intended caller. Nothing in the framework reads it back.
13
+ *
14
+ * The observer lives on the shared graph state rather than in a module `let`, so a bundle
15
+ * carrying two copies of this module still has one observer — the same reason G exists.
16
+ */
17
+ import { G } from './state.js';
18
+ import { VERSION } from '../../../version.generated.js';
19
+ /**
20
+ * Watch the graph. Returns a function that stops watching.
21
+ *
22
+ * One observer at a time — the last to register wins. Two tools watching one page at once is
23
+ * not a case worth carrying state for.
24
+ */
25
+ export function observeReactiveNodes(next) {
26
+ G.observer = next;
27
+ return () => {
28
+ if (G.observer === next)
29
+ G.observer = null;
30
+ };
31
+ }
32
+ /** What is running right now, outermost first. Empty unless something is watching. */
33
+ const running = [];
34
+ /** What the nodes created in here belong to. See ReactiveNodeReport.origin. */
35
+ let origin;
36
+ /** Attribute everything `fn` creates to `owner`. Free when nobody is watching. */
37
+ export function withReactiveOrigin(owner, fn) {
38
+ if (!G.observer)
39
+ return fn();
40
+ const previous = origin;
41
+ origin = owner;
42
+ try {
43
+ return fn();
44
+ }
45
+ finally {
46
+ origin = previous;
47
+ }
48
+ }
49
+ /** Called by the primitives. Not part of the public surface. */
50
+ export function reportReactiveNode(report) {
51
+ const observer = G.observer;
52
+ // Filled here rather than at each call site: the stack is already on hand, and a report
53
+ // costs nothing to build when nobody is watching.
54
+ if (observer) {
55
+ observer.created(report.parents === undefined ? { ...report, parents: running, origin: report.origin ?? origin } : report);
56
+ }
57
+ }
58
+ /** Called around a recompute, so a node can say what it was created inside. */
59
+ export function enterReactiveRun(node) {
60
+ if (!G.observer)
61
+ return false;
62
+ running.push(node);
63
+ return true;
64
+ }
65
+ export function exitReactiveRun() {
66
+ running.pop();
67
+ }
68
+ /** Called from the recompute path, so it stays a property read when nobody is watching. */
69
+ export function reportReactiveRun(node) {
70
+ G.observer?.ran?.(node);
71
+ }
72
+ /** Called from the write path, so it stays a property read when nobody is watching. */
73
+ export function reportReactiveWrite(node, by) {
74
+ G.observer?.wrote?.(node, by);
75
+ }
76
+ /**
77
+ * The node is whatever is running: a binding is set up inside its own render effect. Nothing
78
+ * is pushed when no one is watching, so this stays a property read on the hot path.
79
+ */
80
+ export function reportReactiveBinding(target, kind, name, accessor) {
81
+ const observer = G.observer;
82
+ if (!observer?.bound || !running.length)
83
+ return;
84
+ // The compiler may have stamped the accessor with the hole's line. A stack cannot say it:
85
+ // every binding in a template comes from the same generated expression.
86
+ observer.bound(running[running.length - 1], target, kind, name, accessor);
87
+ }
88
+ /**
89
+ * A component's props, reported where it is created so the running computation is the one
90
+ * the props belong to. Nothing is read: the caller keeps the object and reads it untracked
91
+ * when someone asks.
92
+ */
93
+ export function reportReactiveProps(props) {
94
+ const observer = G.observer;
95
+ if (!observer?.props || !running.length || !props)
96
+ return;
97
+ observer.props(running[running.length - 1], props);
98
+ }
99
+ /**
100
+ * As `reportReactiveBinding`: the node is whatever is running, since a directive is applied
101
+ * while its element is being built. A property read when nobody is watching.
102
+ */
103
+ export function reportReactiveDirective(target, kind, name, accessor) {
104
+ const observer = G.observer;
105
+ if (!observer?.directive || !running.length)
106
+ return;
107
+ observer.directive(running[running.length - 1], target, kind, name, accessor);
108
+ }
109
+ /** Called where the context is made, so a watcher can take the line from its own stack. */
110
+ export function reportReactiveContextCreated(id) {
111
+ G.observer?.contextCreated?.(id);
112
+ }
113
+ /** As the others: the node is whatever is running, and nothing happens without a watcher. */
114
+ export function reportReactiveContext(id, kind, value) {
115
+ const observer = G.observer;
116
+ if (!observer?.context || !running.length)
117
+ return;
118
+ observer.context(running[running.length - 1], id, kind, value);
119
+ }
120
+ export function reportReactiveMove(node, origin, name) {
121
+ G.observer?.moved?.(node, origin, name);
122
+ }
123
+ export function reportReactiveDispose(node) {
124
+ G.observer?.disposed?.(node);
125
+ }
126
+ /**
127
+ * Where a tool that cannot be imported finds the runtime.
128
+ *
129
+ * An extension has no way into an application's module graph, and an application should not
130
+ * have to import a debugger to be debuggable. So a tool sets this global before any of the
131
+ * app loads, and the runtime hands it the door on the way past.
132
+ *
133
+ * Set it too late and nothing happens — the runtime only offers once, when this module is
134
+ * first evaluated. A browser agent has to run at document_start for that reason.
135
+ */
136
+ const HOOK = '__FLUIXI_DEVTOOLS_HOOK__';
137
+ const hook = globalThis[HOOK];
138
+ if (typeof hook?.inject === 'function') {
139
+ try {
140
+ hook.inject({ observeReactiveNodes, version: VERSION });
141
+ }
142
+ catch {
143
+ // A broken tool is not the application's problem.
144
+ }
145
+ }
146
+ /** Whether anything is watching, for a caller that would otherwise do work to report. */
147
+ export function isObserved() {
148
+ return G.observer != null;
149
+ }
@@ -0,0 +1 @@
1
+ var c="__fluixi_signal_next_state__",d=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[c]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:d,onSuspend:null,onError:null,observer:null};var v="1.0.0-alpha.83";function l(e){return o.observer=e,()=>{o.observer===e&&(o.observer=null)}}var r=[],u;function R(e,n){if(!o.observer)return n();let t=u;u=e;try{return n()}finally{u=t}}function g(e){let n=o.observer;n&&n.created(e.parents===void 0?{...e,parents:r,origin:e.origin??u}:e)}function h(e){return o.observer?(r.push(e),!0):!1}function x(){r.pop()}function m(e){o.observer?.ran?.(e)}function O(e,n){o.observer?.wrote?.(e,n)}function y(e,n,t,i){let s=o.observer;!s?.bound||!r.length||s.bound(r[r.length-1],e,n,t,i)}function _(e){let n=o.observer;!n?.props||!r.length||!e||n.props(r[r.length-1],e)}function N(e,n,t,i){let s=o.observer;!s?.directive||!r.length||s.directive(r[r.length-1],e,n,t,i)}function S(e){o.observer?.contextCreated?.(e)}function D(e,n,t){let i=o.observer;!i?.context||!r.length||i.context(r[r.length-1],e,n,t)}function E(e,n,t){o.observer?.moved?.(e,n,t)}function T(e){o.observer?.disposed?.(e)}var p="__FLUIXI_DEVTOOLS_HOOK__",a=globalThis[p];if(typeof a?.inject=="function")try{a.inject({observeReactiveNodes:l,version:v})}catch{}function q(){return o.observer!=null}export{h as enterReactiveRun,x as exitReactiveRun,q as isObserved,l as observeReactiveNodes,y as reportReactiveBinding,D as reportReactiveContext,S as reportReactiveContextCreated,N as reportReactiveDirective,T as reportReactiveDispose,E as reportReactiveMove,g as reportReactiveNode,_ as reportReactiveProps,m as reportReactiveRun,O as reportReactiveWrite,R as withReactiveOrigin};
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(e,n)=>{for(var t in n)C(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ce(n))!de.call(e,s)&&s!==t&&C(e,s,{get:()=>n[s],enumerable:!(o=le(n,s))||o.enumerable});return e};var he=e=>pe(C({},"__esModule",{value:!0}),e);var ke={};fe(ke,{createResource:()=>xe});module.exports=he(ke);var ve="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ve]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var H=0,K=1,v=2,k=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))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);A(this)}}peek(){return this._value}},w=class extends k{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===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(l){i=!0,a=l,s=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);A(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===H;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=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 L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Te(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function V(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)E(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 U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ye(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 Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=Te(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{E(this.owner,!1),N(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>ye(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,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let n=new I(e);return()=>n.dispose()}U(()=>{});var Se=Symbol.for("signal");var be=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let a=typeof i=="function"?i(t.peek()):i;return t.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,be,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function J(e,n){let t=n;return B(()=>{t=e(t)})}function d(e){return $(e)}function j(e){return L(e)}var Q=null;function ne(e){Q&&Q(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ge(e){return!!e&&typeof e.then=="function"}var M=Symbol();function xe(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=t.transport===!1?void 0:re(),a=i!==void 0?te(i):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==M&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;V(()=>g=!0);let z=j(q),ae=j(l),F=z==="ready"||z==="refreshing";d(()=>{f(F?"refreshing":"pending"),y(void 0)});try{let c=s(u,{value:ae,refetching:F});ge(c)?(p(c),ne(c),c.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=G();if(u)throw u;if(W()){let b=se();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}
1
+ "use strict";var A=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var ke=(e,n)=>{for(var t in n)A(e,t,{get:n[t],enumerable:!0})},xe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of ye(n))!ge.call(e,i)&&i!==t&&A(e,i,{get:()=>n[i],enumerable:!(o=me(n,i))||o.enumerable});return e};var Re=e=>xe(A({},"__esModule",{value:!0}),e);var je={};ke(je,{createResource:()=>Ve});module.exports=Re(je);var Se="__fluixi_signal_next_state__",Oe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[Se]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Oe,onSuspend:null,onError:null,observer:null};var U="1.0.0-alpha.83";function _e(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var I=[],Pe;function O(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:I,origin:e.origin??Pe}:e)}function $(e){return r.observer?(I.push(e),!0):!1}function B(){I.pop()}function X(e){r.observer?.ran?.(e)}function J(e,n){r.observer?.wrote?.(e,n)}function _(e){r.observer?.disposed?.(e)}var qe="__FLUIXI_DEVTOOLS_HOOK__",Y=globalThis[qe];if(typeof Y?.inject=="function")try{Y.inject({observeReactiveNodes:_e,version:U})}catch{}function Q(){return r.observer!=null}var Z=0,ee=1,T=2,P=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))}},q=class extends P{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++,J(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(T);V(this)}}peek(){return this._value}},b=class extends P{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;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===ee&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=Z}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=$(this);r.consumer=this,r.untracked=!1;let s,u=!1,f;try{s=this._fn()}catch(c){u=!0,f=c,s=this._value}finally{r.consumer=t,r.untracked=o,i&&B()}let w=!this._initialized||this._threw!==u||(u?f!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=f,this._value=s,X(this),w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(T);V(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Z;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(ee);V(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function V(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=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){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function m(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function j(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)j(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 te(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function De(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 re(){r.batchDepth===0&&D()}function oe(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&D()}}var M=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=Ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{j(this.owner,!1),G(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),O({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new C(()=>De(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,_(this.computed),this.watcher.unwatch(this.computed),j(this.owner))}};function ie(e,n=!1){let t=new M(e,n);return()=>t.dispose()}te(()=>{});var Ee=Symbol.for("signal");var Ae=Symbol.for("signal-node");function h(e,n){let t=new q(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),re(),u});return Object.defineProperty(o,Ee,{value:!0,enumerable:!0}),Object.defineProperty(o,Ae,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),O({kind:"signal",node:t,handle:o,name:n?.name,set:i}),Q()&&m(()=>_(t)),[o,i]}function se(e,n){let t=n;return ie(()=>{t=e(t)},!0)}function d(e){return oe(e)}function W(e){return ne(e)}var ue=null;function de(e){ue&&ue(e)}var ae=null;function fe(e){return ae?ae(e):void 0}var ce=null;function pe(){return ce?ce():void 0}var le=null;function ve(e,n){le&&le(e,n)}function Ie(e){return!!e&&typeof e.then=="function"}var H=Symbol();function Ve(e,n,t={}){let o,i;typeof n=="function"?(o=typeof e=="function"?e:()=>e,i=n):(o=()=>!0,i=e,n&&typeof n=="object"&&(t=n));let s=t.transport===!1?void 0:pe(),u=s!==void 0?fe(s):void 0,f=u!==void 0,[w,c]=h(u!==void 0?u.value:t.initialValue,{equals:!1}),[K,y]=h(void 0,{equals:!1}),[N,p]=h(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[he,v]=h(void 0,{equals:!1}),[we,Te]=h(void 0,{equals:!1}),g=H,E=!1;se(()=>{let a=o();if(we(),a===!1||a===null||a===void 0){g=H,d(()=>{p("unresolved"),v(void 0),y(void 0)});return}let x=E;if(E=!1,g!==H&&a===g&&!x)return;if(g=a,f){f=!1;return}let R=!1;m(()=>R=!0);let F=W(N),be=W(w),L=F==="ready"||F==="refreshing";d(()=>{p(L?"refreshing":"pending"),y(void 0)});try{let l=i(a,{value:be,refetching:L});Ie(l)?(v(l),de(l),l.then(S=>{R||(s!==void 0&&ve(s,S),d(()=>{c(()=>S),p("ready"),v(void 0)}))},S=>{R||d(()=>{y(S),p("errored"),v(void 0)})})):d(()=>{c(()=>l),p("ready"),v(void 0)})}catch(l){if(R)return;d(()=>{y(l),p("errored"),v(void 0)})}});let z=()=>{let a=N();return a==="pending"||a==="refreshing"},k=(()=>{let a=K();if(a)throw a;if(z()){let x=he();if(x)throw x}return w()});return Object.defineProperties(k,{state:{get:N},loading:{get:z},error:{get:K},latest:{get:w}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:c,refetch:()=>{E=!0,Te(void 0)}}]}
@@ -1 +1 @@
1
- var ae="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var F=0,H=1,v=2,k=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))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);C(this)}}peek(){return this._value}},w=class extends k{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===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;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}let T=!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,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);C(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===F;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(H);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=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 K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function A(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)A(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 L(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function de(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 U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{A(this.owner,!1),I(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>de(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,this.watcher.unwatch(this.computed),A(this.owner))}};function $(e){let n=new E(e);return()=>n.dispose()}L(()=>{});var pe=Symbol.for("signal");var he=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let a=typeof s=="function"?s(t.peek()):s;return t.set(a),U(),a});return Object.defineProperty(o,pe,{value:!0,enumerable:!0}),Object.defineProperty(o,he,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function B(e,n){let t=n;return $(()=>{t=e(t)})}function d(e){return Y(e)}function V(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function ne(e){return Q?Q(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,n){Z&&Z(e,n)}function ve(e){return!!e&&typeof e.then=="function"}var j=Symbol();function Ae(e,n,t={}){let o,i;typeof n=="function"?(o=typeof e=="function"?e:()=>e,i=n):(o=()=>!0,i=e,n&&typeof n=="object"&&(t=n));let s=t.transport===!1?void 0:te(),a=s!==void 0?ne(s):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[oe,p]=h(void 0,{equals:!1}),[se,ie]=h(void 0,{equals:!1}),m=j,D=!1;B(()=>{let u=o();if(se(),u===!1||u===null||u===void 0){m=j,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==j&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;N(()=>g=!0);let W=V(q),ue=V(l),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let c=i(u,{value:ue,refetching:z});ve(c)?(p(c),ee(c),c.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=M();if(u)throw u;if(G()){let b=oe();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ie(void 0)}}]}export{Ae as createResource};
1
+ var be="__fluixi_signal_next_state__",me=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[be]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:me,onSuspend:null,onError:null,observer:null};var L="1.0.0-alpha.83";function ye(e){return r.observer=e,()=>{r.observer===e&&(r.observer=null)}}var A=[],ge;function O(e){let n=r.observer;n&&n.created(e.parents===void 0?{...e,parents:A,origin:e.origin??ge}:e)}function Y(e){return r.observer?(A.push(e),!0):!1}function $(){A.pop()}function B(e){r.observer?.ran?.(e)}function X(e,n){r.observer?.wrote?.(e,n)}function _(e){r.observer?.disposed?.(e)}var ke="__FLUIXI_DEVTOOLS_HOOK__",U=globalThis[ke];if(typeof U?.inject=="function")try{U.inject({observeReactiveNodes:ye,version:L})}catch{}function J(){return r.observer!=null}var Q=0,Z=1,T=2,P=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))}},q=class extends P{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++,X(this,r.consumer),this.observers)for(let t of[...this.observers])t.markDirty(T);I(this)}}peek(){return this._value}},b=class extends P{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=T;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===Z&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===T)break}(this.state===T||!this._initialized)&&this.recompute(),this.state=Q}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked,a=Y(this);r.consumer=this,r.untracked=!1;let i,s=!1,f;try{i=this._fn()}catch(c){s=!0,f=c,i=this._value}finally{r.consumer=t,r.untracked=o,a&&$()}let w=!this._initialized||this._threw!==s||(s?f!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=f,this._value=i,B(this),w){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(T);I(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Q;if(this.state=t,o){if(this.observers)for(let a of[...this.observers])a.markDirty(Z);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=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 ee(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function xe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function m(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(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 ne(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Re(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 te(){r.batchDepth===0&&D()}function re(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&D()}}var j=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=xe(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{V(this.owner,!1),M(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),O({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new C(()=>Re(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,_(this.computed),this.watcher.unwatch(this.computed),V(this.owner))}};function oe(e,n=!1){let t=new j(e,n);return()=>t.dispose()}ne(()=>{});var Oe=Symbol.for("signal");var _e=Symbol.for("signal-node");function h(e,n){let t=new q(e,{equals:n?.equals}),o=(()=>t.get()),a=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),te(),s});return Object.defineProperty(o,Oe,{value:!0,enumerable:!0}),Object.defineProperty(o,_e,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),O({kind:"signal",node:t,handle:o,name:n?.name,set:a}),J()&&m(()=>_(t)),[o,a]}function ie(e,n){let t=n;return oe(()=>{t=e(t)},!0)}function d(e){return re(e)}function G(e){return ee(e)}var se=null;function le(e){se&&se(e)}var ue=null;function de(e){return ue?ue(e):void 0}var ae=null;function fe(){return ae?ae():void 0}var ce=null;function pe(e,n){ce&&ce(e,n)}function Pe(e){return!!e&&typeof e.then=="function"}var W=Symbol();function en(e,n,t={}){let o,a;typeof n=="function"?(o=typeof e=="function"?e:()=>e,a=n):(o=()=>!0,a=e,n&&typeof n=="object"&&(t=n));let i=t.transport===!1?void 0:fe(),s=i!==void 0?de(i):void 0,f=s!==void 0,[w,c]=h(s!==void 0?s.value:t.initialValue,{equals:!1}),[H,y]=h(void 0,{equals:!1}),[N,p]=h(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[ve,v]=h(void 0,{equals:!1}),[he,we]=h(void 0,{equals:!1}),g=W,E=!1;ie(()=>{let u=o();if(he(),u===!1||u===null||u===void 0){g=W,d(()=>{p("unresolved"),v(void 0),y(void 0)});return}let x=E;if(E=!1,g!==W&&u===g&&!x)return;if(g=u,f){f=!1;return}let R=!1;m(()=>R=!0);let z=G(N),Te=G(w),F=z==="ready"||z==="refreshing";d(()=>{p(F?"refreshing":"pending"),y(void 0)});try{let l=a(u,{value:Te,refetching:F});Pe(l)?(v(l),le(l),l.then(S=>{R||(i!==void 0&&pe(i,S),d(()=>{c(()=>S),p("ready"),v(void 0)}))},S=>{R||d(()=>{y(S),p("errored"),v(void 0)})})):d(()=>{c(()=>l),p("ready"),v(void 0)})}catch(l){if(R)return;d(()=>{y(l),p("errored"),v(void 0)})}});let K=()=>{let u=N();return u==="pending"||u==="refreshing"},k=(()=>{let u=H();if(u)throw u;if(K()){let x=ve();if(x)throw x}return w()});return Object.defineProperties(k,{state:{get:N},loading:{get:K},error:{get:H},latest:{get:w}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:c,refetch:()=>{E=!0,we(void 0)}}]}export{en as createResource};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var r in t)w(e,r,{get:t[r],enumerable:!0})},q=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of k(t))!g.call(e,o)&&o!==r&&w(e,o,{get:()=>t[o],enumerable:!(s=S(t,o))||s.enumerable});return e};var C=e=>q(w({},"__esModule",{value:!0}),e);var Q={};O(Q,{afterWrite:()=>U,batch:()=>B,createChildOwner:()=>N,createContext:()=>I,createRoot:()=>Y,disposeScope:()=>P,effect:()=>J,flushSync:()=>f,getOwner:()=>H,isOwnerDisposed:()=>z,onCleanup:()=>K,provide:()=>M,readContextFrom:()=>R,reportSuspend:()=>A,runWithOwner:()=>x,setErrorHandler:()=>F,setOwner:()=>V,setScheduler:()=>j,setSuspendHandler:()=>W,useContext:()=>G});module.exports=C(Q);var E="__fluixi_signal_next_state__",D=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var T=0,_=1,d=2,v=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 c=class extends v{constructor(r,s){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=s?.equals===!1?()=>!1:s?.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===_&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=T}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=n.consumer,s=n.untracked;n.consumer=this,n.untracked=!1;let o,i=!1,p;try{o=this._fn()}catch(u){i=!0,p=u,o=this._value}finally{n.consumer=r,n.untracked=s}let m=!this._initialized||this._threw!==i||(i?p!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=p,this._value=o,m){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(d);b(this)}}markDirty(r){if(this.state>=r)return;let s=this.state===T;if(this.state=r,s){if(this.observers)for(let o of[...this.observers])o.markDirty(_);b(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function b(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var h=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 N(e){let t=l(e);return e&&(e.owned??=[]).push(t),t}function P(e,t=!0){a(e,t)}function z(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:s=>{let o=n.owner,i=l(o);(i.contexts=new Map).set(t,s.value),o&&(o.owned??=[]).push(i),n.owner=i;try{return s.children}finally{n.owner=o}}}}function G(e){let t=n.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function R(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let s=l(n.owner);(s.contexts=new Map).set(e.id,t),n.owner&&(n.owner.owned??=[]).push(s);let o=n.owner;n.owner=s;try{return r()}finally{n.owner=o}}function W(e){n.onSuspend=e}function A(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function F(e){n.onError=e}function H(){return n.owner}function V(e){let t=n.owner;return n.owner=e,t}function x(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 a(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)a(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 Y(e){let t=l(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>a(t))}finally{n.owner=r}}function j(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function L(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(f)))}function f(){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 U(){n.batchDepth===0&&f()}function B(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&f()}}var y=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=l(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{a(this.owner,!1),x(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new h(()=>L(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&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,this.watcher.unwatch(this.computed),a(this.owner))}};function J(e){let t=new y(e);return()=>t.dispose()}
1
+ "use strict";var k=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var z=(e,n)=>{for(var r in n)k(e,r,{get:n[r],enumerable:!0})},G=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of H(n))!V.call(e,i)&&i!==r&&k(e,i,{get:()=>n[i],enumerable:!(o=I(n,i))||o.enumerable});return e};var K=e=>G(k({},"__esModule",{value:!0}),e);var de={};z(de,{afterWrite:()=>ue,batch:()=>ae,createChildOwner:()=>L,createContext:()=>B,createRoot:()=>oe,disposeScope:()=>Y,effect:()=>ce,flushSync:()=>w,getOwner:()=>ne,isOwnerDisposed:()=>U,onCleanup:()=>re,provide:()=>Q,readContextFrom:()=>J,reportSuspend:()=>$,runWithOwner:()=>E,setErrorHandler:()=>ee,setOwner:()=>te,setScheduler:()=>ie,setSuspendHandler:()=>Z,useContext:()=>X});module.exports=K(de);var W="__fluixi_signal_next_state__",M=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},t=globalThis[W]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:M,onSuspend:null,onError:null,observer:null};var m="1.0.0-alpha.83";function j(e){return t.observer=e,()=>{t.observer===e&&(t.observer=null)}}var a=[],F;function _(e){let n=t.observer;n&&n.created(e.parents===void 0?{...e,parents:a,origin:e.origin??F}:e)}function T(e){return t.observer?(a.push(e),!0):!1}function R(){a.pop()}function O(e){t.observer?.ran?.(e)}function S(e){t.observer?.contextCreated?.(e)}function f(e,n,r){let o=t.observer;!o?.context||!a.length||o.context(a[a.length-1],e,n,r)}function C(e){t.observer?.disposed?.(e)}var A="__FLUIXI_DEVTOOLS_HOOK__",g=globalThis[A];if(typeof g?.inject=="function")try{g.inject({observeReactiveNodes:j,version:m})}catch{}var q=0,N=1,h=2,y=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 v=class extends y{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=h;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===N&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===h)break}(this.state===h||!this._initialized)&&this.recompute(),this.state=q}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=T(this);t.consumer=this,t.untracked=!1;let s,u=!1,b;try{s=this._fn()}catch(c){u=!0,b=c,s=this._value}finally{t.consumer=r,t.untracked=o,i&&R()}let P=!this._initialized||this._threw!==u||(u?b!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=b,this._value=s,O(this),P){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(h);D(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===q;if(this.state=r,o){if(this.observers)for(let i of[...this.observers])i.markDirty(N);D(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function D(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var p=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let r of n)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...n){for(let r of n)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let r=this._pending.size===0;this._pending.add(n),r&&this._notifyFn()}};function L(e){let n=l(e);return e&&(e.owned??=[]).push(n),n}function Y(e,n=!0){d(e,n)}function U(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function B(e,n){let r=Symbol(n??"context");return S(r),{id:r,defaultValue:e,Provider:i=>{f(r,"provide",i.value);let s=t.owner,u=l(s);(u.contexts=new Map).set(r,i.value),s&&(s.owned??=[]).push(u),t.owner=u;try{return i.children}finally{t.owner=s}}}}function X(e){let n=t.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id)){let r=n.contexts.get(e.id);return f(e.id,"read",r),r}n=n.parent}return f(e.id,"read",e.defaultValue),e.defaultValue}function J(e,n){let r=e;for(;r;){if(r.contexts&&r.contexts.has(n.id))return r.contexts.get(n.id);r=r.parent}return n.defaultValue}function Q(e,n,r){let o=l(t.owner);(o.contexts=new Map).set(e.id,n),t.owner&&(t.owner.owned??=[]).push(o);let i=t.owner;t.owner=o;try{return r()}finally{t.owner=i}}function Z(e){t.onSuspend=e}function $(e){return t.onSuspend?(t.onSuspend(e,t.owner),!0):!1}function ee(e){t.onError=e}function ne(){return t.owner}function te(e){let n=t.owner;return t.owner=e,n}function E(e,n){let r=t.owner;t.owner=e;try{return n()}finally{t.owner=r}}function re(e){if(t.owner){if(t.owner.disposed){e();return}(t.owner.cleanups??=[]).push(e)}}function d(e,n=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)d(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}n&&(e.disposed=!0)}}function oe(e){let n=l(t.owner);t.owner&&(t.owner.owned??=[]).push(n);let r=t.owner;t.owner=n;try{return e(()=>d(n))}finally{t.owner=r}}function ie(e){t.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function se(e){e.queued||(e.queued=!0,t.queue.push(e),!t.scheduled&&t.batchDepth===0&&(t.scheduled=!0,t.hostSchedule(w)))}function w(){if(t.scheduled=!1,t.flushing)return;t.flushing=!0;let e=0;try{for(;t.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=t.queue;t.queue=[];for(let r of n)r.queued=!1,r.disposed||r.run()}}finally{t.flushing=!1}}function ue(){t.batchDepth===0&&w()}function ae(e){t.batchDepth++;try{return e()}finally{--t.batchDepth===0&&w()}}var x=class{constructor(n,r=!1){this.queued=!1;this.disposed=!1;this.owner=l(t.owner),t.owner&&(t.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new v(()=>{d(this.owner,!1),E(this.owner,()=>{let o=n();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),_({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new p(()=>se(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"&&t.onSuspend){t.onSuspend(n,this.owner);return}if(t.onError&&t.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,C(this.computed),this.watcher.unwatch(this.computed),d(this.owner))}};function ce(e,n=!1){let r=new x(e,n);return()=>r.dispose()}
@@ -36,7 +36,7 @@ export interface Context<T> {
36
36
  debug?: boolean;
37
37
  }) => any;
38
38
  }
39
- export declare function createContext<T>(defaultValue?: T): Context<T>;
39
+ export declare function createContext<T>(defaultValue?: T, name?: string): Context<T>;
40
40
  /** Read the nearest provided value for `context`, or its default. */
41
41
  export declare function useContext<T>(context: {
42
42
  id: symbol;
@@ -73,5 +73,5 @@ export declare function afterWrite(): void;
73
73
  /** Group writes so dependent effects flush once, at the end. */
74
74
  export declare function batch<T>(fn: () => T): T;
75
75
  /** A re-running side effect. Runs once now, then again (G.scheduled) when deps change. */
76
- export declare function effect(fn: () => void | (() => void)): () => void;
76
+ export declare function effect(fn: () => void | (() => void), report?: boolean): () => void;
77
77
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/runtime.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/runtime.ts"],"names":[],"mappings":"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"}
@@ -16,6 +16,7 @@
16
16
  */
17
17
  import { Computed, Watcher } from './core.js';
18
18
  import { G } from './state.js';
19
+ import { reportReactiveContext, reportReactiveContextCreated, reportReactiveDispose, reportReactiveNode, } from './observe.js';
19
20
  /**
20
21
  * A child scope of `parent`, attached so the parent's teardown disposes it too.
21
22
  *
@@ -48,8 +49,10 @@ export function isOwnerDisposed(owner) {
48
49
  function makeOwner(parent) {
49
50
  return { cleanups: null, owned: null, parent, contexts: null };
50
51
  }
51
- export function createContext(defaultValue) {
52
- const id = Symbol('context');
52
+ export function createContext(defaultValue, name) {
53
+ // Named so a watcher can tell two of them apart. Nothing else reads the description.
54
+ const id = Symbol(name ?? 'context');
55
+ reportReactiveContextCreated(id);
53
56
  const Provider = (props) => {
54
57
  // Stamp the value on a DEDICATED child owner, then read `children` under it — never
55
58
  // on the current owner directly. Two sibling <Ctx.Provider> elements used inline (no
@@ -58,6 +61,7 @@ export function createContext(defaultValue) {
58
61
  // A child scope isolates each Provider; because createMemo captures the owner at
59
62
  // creation, the children memos built while reading `props.children` here capture this
60
63
  // scope and resolve the right value even when rendered lazily (Portal/Show/For).
64
+ reportReactiveContext(id, 'provide', props.value);
61
65
  const parent = G.owner;
62
66
  const owner = makeOwner(parent);
63
67
  (owner.contexts = new Map()).set(id, props.value);
@@ -77,10 +81,14 @@ export function createContext(defaultValue) {
77
81
  export function useContext(context) {
78
82
  let o = G.owner;
79
83
  while (o) {
80
- if (o.contexts && o.contexts.has(context.id))
81
- return o.contexts.get(context.id);
84
+ if (o.contexts && o.contexts.has(context.id)) {
85
+ const found = o.contexts.get(context.id);
86
+ reportReactiveContext(context.id, 'read', found);
87
+ return found;
88
+ }
82
89
  o = o.parent;
83
90
  }
91
+ reportReactiveContext(context.id, 'read', context.defaultValue);
84
92
  return context.defaultValue;
85
93
  }
86
94
  /** Read `context` starting from a specific owner chain (not the current scope). */
@@ -260,7 +268,7 @@ class EffectNode {
260
268
  owner;
261
269
  queued = false;
262
270
  disposed = false;
263
- constructor(fn) {
271
+ constructor(fn, report = false) {
264
272
  this.owner = makeOwner(G.owner);
265
273
  // Tie disposal to the creating scope: when the parent owner tears down it must
266
274
  // fully dispose this effect (unwatch + body cleanups), not just run the body
@@ -279,6 +287,10 @@ class EffectNode {
279
287
  (this.owner.cleanups ??= []).push(r);
280
288
  });
281
289
  });
290
+ // Before the first run, so a watcher counts that run like every later one. A render
291
+ // effect is reported too, marked as plumbing: it is not worth drawing, but a node made
292
+ // inside one has to be able to find its way back to the component that caused it.
293
+ reportReactiveNode({ kind: 'effect', node: this.computed, handle: this, internal: !report });
282
294
  // The watcher only schedules; the recompute happens on flush.
283
295
  this.watcher = new Watcher(() => enqueue(this));
284
296
  this.run(); // initial synchronous run (Solid semantics)
@@ -309,12 +321,15 @@ class EffectNode {
309
321
  if (this.disposed)
310
322
  return;
311
323
  this.disposed = true;
324
+ reportReactiveDispose(this.computed);
312
325
  this.watcher.unwatch(this.computed);
313
326
  disposeOwner(this.owner);
314
327
  }
315
328
  }
316
329
  /** A re-running side effect. Runs once now, then again (G.scheduled) when deps change. */
317
- export function effect(fn) {
318
- const node = new EffectNode(fn);
330
+ export function effect(fn, report = false) {
331
+ // Reported only when the caller says so. Every DOM binding is a render effect through this
332
+ // same factory, and a graph holding one node per text node is not a graph anyone reads.
333
+ const node = new EffectNode(fn, report);
319
334
  return () => node.dispose();
320
335
  }
@@ -1 +1 @@
1
- var x="__fluixi_signal_next_state__",m=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},t=globalThis[x]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:m,onSuspend:null,onError:null};var y=0,T=1,d=2,p=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 c=class extends p{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=d;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===T&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=y}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=t.consumer,o=t.untracked;t.consumer=this,t.untracked=!1;let s,i=!1,f;try{s=this._fn()}catch(u){i=!0,f=u,s=this._value}finally{t.consumer=r,t.untracked=o}let b=!this._initialized||this._threw!==i||(i?f!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=f,this._value=s,b){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(d);_(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===y;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(T);_(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var h=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let r of n)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...n){for(let r of n)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let r=this._pending.size===0;this._pending.add(n),r&&this._notifyFn()}};function D(e){let n=l(e);return e&&(e.owned??=[]).push(n),n}function N(e,n=!0){a(e,n)}function P(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function z(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:o=>{let s=t.owner,i=l(s);(i.contexts=new Map).set(n,o.value),s&&(s.owned??=[]).push(i),t.owner=i;try{return o.children}finally{t.owner=s}}}}function I(e){let n=t.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function G(e,n){let r=e;for(;r;){if(r.contexts&&r.contexts.has(n.id))return r.contexts.get(n.id);r=r.parent}return n.defaultValue}function R(e,n,r){let o=l(t.owner);(o.contexts=new Map).set(e.id,n),t.owner&&(t.owner.owned??=[]).push(o);let s=t.owner;t.owner=o;try{return r()}finally{t.owner=s}}function M(e){t.onSuspend=e}function W(e){return t.onSuspend?(t.onSuspend(e,t.owner),!0):!1}function A(e){t.onError=e}function F(){return t.owner}function H(e){let n=t.owner;return t.owner=e,n}function S(e,n){let r=t.owner;t.owner=e;try{return n()}finally{t.owner=r}}function V(e){if(t.owner){if(t.owner.disposed){e();return}(t.owner.cleanups??=[]).push(e)}}function a(e,n=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)a(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}n&&(e.disposed=!0)}}function K(e){let n=l(t.owner);t.owner&&(t.owner.owned??=[]).push(n);let r=t.owner;t.owner=n;try{return e(()=>a(n))}finally{t.owner=r}}function Y(e){t.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function k(e){e.queued||(e.queued=!0,t.queue.push(e),!t.scheduled&&t.batchDepth===0&&(t.scheduled=!0,t.hostSchedule(v)))}function v(){if(t.scheduled=!1,t.flushing)return;t.flushing=!0;let e=0;try{for(;t.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=t.queue;t.queue=[];for(let r of n)r.queued=!1,r.disposed||r.run()}}finally{t.flushing=!1}}function j(){t.batchDepth===0&&v()}function L(e){t.batchDepth++;try{return e()}finally{--t.batchDepth===0&&v()}}var w=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=l(t.owner),t.owner&&(t.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{a(this.owner,!1),S(this.owner,()=>{let r=n();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new h(()=>k(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"&&t.onSuspend){t.onSuspend(n,this.owner);return}if(t.onError&&t.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),a(this.owner))}};function U(e){let n=new w(e);return()=>n.dispose()}export{j as afterWrite,L as batch,D as createChildOwner,z as createContext,K as createRoot,N as disposeScope,U as effect,v as flushSync,F as getOwner,P as isOwnerDisposed,V as onCleanup,R as provide,G as readContextFrom,W as reportSuspend,S as runWithOwner,A as setErrorHandler,H as setOwner,Y as setScheduler,M as setSuspendHandler,I as useContext};
1
+ var E="__fluixi_signal_next_state__",P=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:P,onSuspend:null,onError:null,observer:null};var x="1.0.0-alpha.83";function I(e){return n.observer=e,()=>{n.observer===e&&(n.observer=null)}}var a=[],H;function g(e){let t=n.observer;t&&t.created(e.parents===void 0?{...e,parents:a,origin:e.origin??H}:e)}function _(e){return n.observer?(a.push(e),!0):!1}function T(){a.pop()}function R(e){n.observer?.ran?.(e)}function O(e){n.observer?.contextCreated?.(e)}function f(e,t,r){let o=n.observer;!o?.context||!a.length||o.context(a[a.length-1],e,t,r)}function S(e){n.observer?.disposed?.(e)}var V="__FLUIXI_DEVTOOLS_HOOK__",m=globalThis[V];if(typeof m?.inject=="function")try{m.inject({observeReactiveNodes:I,version:x})}catch{}var C=0,q=1,h=2,b=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 v=class extends b{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=h;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===q&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===h)break}(this.state===h||!this._initialized)&&this.recompute(),this.state=C}recompute(){if(this.sources){for(let c of this.sources)c.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked,i=_(this);n.consumer=this,n.untracked=!1;let s,u=!1,w;try{s=this._fn()}catch(c){u=!0,w=c,s=this._value}finally{n.consumer=r,n.untracked=o,i&&T()}let D=!this._initialized||this._threw!==u||(u?w!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=w,this._value=s,R(this),D){if(this.version++,this.observers)for(let c of[...this.observers])c.markDirty(h);N(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===C;if(this.state=r,o){if(this.observers)for(let i of[...this.observers])i.markDirty(q);N(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function N(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var p=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 Q(e){let t=l(e);return e&&(e.owned??=[]).push(t),t}function Z(e,t=!0){d(e,t)}function $(e){return!!e&&e.disposed===!0}function l(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function ee(e,t){let r=Symbol(t??"context");return O(r),{id:r,defaultValue:e,Provider:i=>{f(r,"provide",i.value);let s=n.owner,u=l(s);(u.contexts=new Map).set(r,i.value),s&&(s.owned??=[]).push(u),n.owner=u;try{return i.children}finally{n.owner=s}}}}function ne(e){let t=n.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id)){let r=t.contexts.get(e.id);return f(e.id,"read",r),r}t=t.parent}return f(e.id,"read",e.defaultValue),e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function re(e,t,r){let o=l(n.owner);(o.contexts=new Map).set(e.id,t),n.owner&&(n.owner.owned??=[]).push(o);let i=n.owner;n.owner=o;try{return r()}finally{n.owner=i}}function oe(e){n.onSuspend=e}function ie(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function se(e){n.onError=e}function ue(){return n.owner}function ae(e){let t=n.owner;return n.owner=e,t}function z(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function ce(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function d(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)d(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 de(e){let t=l(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>d(t))}finally{n.owner=r}}function le(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function G(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(y)))}function y(){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 fe(){n.batchDepth===0&&y()}function he(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&y()}}var k=class{constructor(t,r=!1){this.queued=!1;this.disposed=!1;this.owner=l(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new v(()=>{d(this.owner,!1),z(this.owner,()=>{let o=t();typeof o=="function"&&(this.owner.cleanups??=[]).push(o)})}),g({kind:"effect",node:this.computed,handle:this,internal:!r}),this.watcher=new p(()=>G(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,S(this.computed),this.watcher.unwatch(this.computed),d(this.owner))}};function ve(e,t=!1){let r=new k(e,t);return()=>r.dispose()}export{fe as afterWrite,he as batch,Q as createChildOwner,ee as createContext,de as createRoot,Z as disposeScope,ve as effect,y as flushSync,ue as getOwner,$ as isOwnerDisposed,ce as onCleanup,re as provide,te as readContextFrom,ie as reportSuspend,z as runWithOwner,se as setErrorHandler,ae as setOwner,le as setScheduler,oe as setSuspendHandler,ne as useContext};
@@ -1 +1 @@
1
- "use strict";var se=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var cn=Object.prototype.hasOwnProperty;var ln=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},dn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of an(n))!cn.call(e,o)&&o!==t&&se(e,o,{get:()=>n[o],enumerable:!(r=un(n,o))||r.enumerable});return e};var fn=e=>dn(se({},"__esModule",{value:!0}),e);var An={};ln(An,{$PROXY:()=>Cn,$SIGNAL:()=>En,Signal:()=>on,SuspenseContext:()=>oe,__DEV__:()=>Q,batch:()=>b,createChildOwner:()=>ke,createComputed:()=>Ie,createContext:()=>q,createDebounce:()=>Qe,createDebouncedResource:()=>Xe,createDebouncedSignal:()=>me,createDeferred:()=>Ye,createEffect:()=>E,createErrorBoundary:()=>tn,createMemo:()=>S,createRenderEffect:()=>Me,createResource:()=>te,createRoot:()=>O,createSelector:()=>Ke,createSignal:()=>d,createSuspenseBoundary:()=>Ze,disposeScope:()=>Re,flush:()=>Fe,getOwner:()=>j,getServerData:()=>Z,indexArray:()=>xn,isComponent:()=>Le,isMemo:()=>Ne,isOwnerDisposed:()=>_e,isProvider:()=>We,isResource:()=>Ve,isSignal:()=>X,isSuspense:()=>je,keyArray:()=>Sn,makeArrayFlat:()=>de,mapArray:()=>wn,nextResourceId:()=>ee,on:()=>Be,onCleanup:()=>v,provide:()=>I,provideErrorBoundary:()=>rn,provideSuspense:()=>en,readChildren:()=>Je,reportResourceData:()=>ne,runWithOwner:()=>M,setOwner:()=>ae,setResourceDataSink:()=>He,setResourceIdSource:()=>$e,setResourceTracker:()=>Ge,setServerDataGetter:()=>ze,startTransition:()=>le,trackResourcePromise:()=>J,untrack:()=>w,useContext:()=>Oe,useTransition:()=>Ue});module.exports=fn(An);var pn="__fluixi_signal_next_state__",hn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[pn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:hn,onSuspend:null,onError:null};var Se=0,xe=1,B=2,H=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let n=s.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends H{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(B);ie(this)}}peek(){return this._value}},k=class extends H{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=B;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===xe&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===B)break}(this.state===B||!this._initialized)&&this.recompute(),this.state=Se}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=s.consumer,r=s.untracked;s.consumer=this,s.untracked=!1;let o,u=!1,a;try{o=this._fn()}catch(i){u=!0,a=i,o=this._value}finally{s.consumer=t,s.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=u,this._error=a,this._value=o,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(B);ie(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Se;if(this.state=t,r){if(this.observers)for(let o of[...this.observers])o.markDirty(xe);ie(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ie(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function N(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function be(){return s.consumer}function ge(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ke(e){let n=L(e);return e&&(e.owned??=[]).push(n),n}function Re(e,n=!0){V(e,n)}function _e(e){return!!e&&e.disposed===!0}function L(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let o=s.owner,u=L(o);(u.contexts=new Map).set(n,r.value),o&&(o.owned??=[]).push(u),s.owner=u;try{return r.children}finally{s.owner=o}}}}function Oe(e){let n=s.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function I(e,n,t){let r=L(s.owner);(r.contexts=new Map).set(e.id,n),s.owner&&(s.owner.owned??=[]).push(r);let o=s.owner;s.owner=r;try{return t()}finally{s.owner=o}}function Ee(e){s.onSuspend=e}function Ce(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function Ae(e){s.onError=e}function j(){return s.owner}function ae(e){let n=s.owner;return s.owner=e,n}function M(e,n){let t=s.owner;s.owner=e;try{return n()}finally{s.owner=t}}function v(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(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 O(e){let n=L(s.owner);s.owner&&(s.owner.owned??=[]).push(n);let t=s.owner;s.owner=n;try{return e(()=>V(n))}finally{s.owner=t}}function De(e){s.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function yn(e){e.queued||(e.queued=!0,s.queue.push(e),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(W)))}function W(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=s.queue;s.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function Pe(){s.batchDepth===0&&W()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&W()}}var ue=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=L(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new P(()=>yn(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"&&s.onSuspend){s.onSuspend(n,this.owner);return}if(s.onError&&s.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Y(e){let n=new ue(e);return()=>n.dispose()}function Tn(e){return!!e&&typeof e.then=="function"}De(()=>{});var qe=Symbol.for("signal"),mn=Symbol.for("memo"),vn=Symbol.for("signal-node");function d(e,n){let t=new D(e,{equals:n?.equals}),r=(()=>t.get()),o=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Pe(),a});return Object.defineProperty(r,qe,{value:!0,enumerable:!0}),Object.defineProperty(r,vn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,o]}function S(e,n,t){let r=n,o=j(),u=new k(()=>M(o,()=>{try{return r=e(r)}catch(c){if(Tn(c))return Ce(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,qe,{value:!0,enumerable:!0}),Object.defineProperty(a,mn,{value:!0,enumerable:!0}),a}function E(e,n){let t=n;return Y(()=>{t=e(t)})}function Ie(e,n){let t=n;Y(()=>{t=e(t)})}function Me(e,n){let t=n;return Y(()=>{t=e(t)})}function b(e){return ce(e)}function w(e){return N(e)}function le(e){return ce(e),Promise.resolve()}function Ue(){return[()=>!1,le]}function Fe(){return W(),Promise.resolve()}function Be(e,n,t){let r=Array.isArray(e),o,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,o=c;return}let i=N(()=>n(c,o,a));return o=c,i}}function wn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<o.length;i++){let f=o[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,y;O(T=>{y=T;let[C,U]=d(i);p=U,l=n(f,C)});let x={item:f,rendered:l,dispose:y,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Sn(e,n,t,r){let o=[],u=[];return v(()=>{for(let a of u)a.dispose();o=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return o=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),y=c.get(p);if(y&&!h.has(p))y.setIndex(l),i.push(y);else{let x,T,C;O(U=>{C=U;let[R,F]=d(l);T=F;let G=S(A=>{let g=(e()||[])[R()];return g??A},a[l]);x=t(G,R)}),i.push({rendered:x,dispose:C,setIndex:T})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return o=f,u=i,i.map(l=>l.rendered)})})}function xn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=o.length;for(let i=u;i<a;i++){let f,h,l,p=o[i];O(y=>{l=y;let[x,T]=d(p);h=T,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(o[i]);return r.map(i=>i.rendered)})})}var bn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,Q=typeof process>"u"?bn:!1,gn=Symbol.for("signal"),kn=Symbol.for("memo"),Rn=Symbol.for("resource");function X(e){return typeof e=="function"&&e[gn]===!0}function Ne(e){return typeof e=="function"&&e[kn]===!0}function Ve(e){return typeof e=="function"&&e[Rn]===!0}function Le(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function We(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function de(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?de(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var fe=null;function Ge(e){fe=e}function J(e){fe&&fe(e)}var pe=null;function ze(e){pe=e}function Z(e){return pe?pe(e):void 0}var he=null;function $e(e){he=e}function ee(){return he?he():void 0}var ye=null;function He(e){ye=e}function ne(e,n){ye&&ye(e,n)}function Ke(e,n=(t,r)=>t===r){let t=new Map;return E(()=>{let r=e();for(let[o,u]of t){let[a,c]=u,i=n(o,r);a()!==i&&c(i)}}),r=>{let o=t.get(r);if(!o){let[u,a]=d(!1);o=[u,a],t.set(r,o);let c=e();a(n(r,c))}return o[0]()}}function Ye(e,n){let[t,r]=d(e(),n);return E(()=>{let o=e();n?.timeoutMs?setTimeout(()=>r(()=>o),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),t}function Qe(e,n){let t,r=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function _n(e){return!!e&&typeof e.then=="function"}var Te=Symbol();function te(e,n,t={}){let r,o;typeof n=="function"?(r=typeof e=="function"?e:()=>e,o=n):(r=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ee(),a=u!==void 0?Z(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,y]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,U]=d(void 0,{equals:!1}),R=Te,F=!1;E(()=>{let m=r();if(C(),m===!1||m===null||m===void 0){R=Te,b(()=>{y("unresolved"),T(void 0),l(void 0)});return}let g=F;if(F=!1,R!==Te&&m===R&&!g)return;if(R=m,c){c=!1;return}let z=!1;v(()=>z=!0);let ve=w(p),sn=w(i),we=ve==="ready"||ve==="refreshing";b(()=>{y(we?"refreshing":"pending"),l(void 0)});try{let _=o(m,{value:sn,refetching:we});_n(_)?(T(_),J(_),_.then($=>{z||(u!==void 0&&ne(u,$),b(()=>{f(()=>$),y("ready"),T(void 0)}))},$=>{z||b(()=>{l($),y("errored"),T(void 0)})})):b(()=>{f(()=>_),y("ready"),T(void 0)})}catch(_){if(z)return;b(()=>{l(_),y("errored"),T(void 0)})}});let G=()=>{let m=p();return m==="pending"||m==="refreshing"},A=(()=>{let m=h();if(m)throw m;if(G()){let g=x();if(g)throw g}return i()});return Object.defineProperties(A,{state:{get:p},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(A,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(A,Symbol.for("signal"),{value:!0,enumerable:!0}),[A,{mutate:f,refetch:()=>{F=!0,U(void 0)}}]}function me(e,n=300){let[t,r]=d(e),[o,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let y=typeof p=="function"?p(w(t)):p;return r(()=>y),c(!0),f(),i=setTimeout(h,n),y});return v(f),[o,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function On(e){return e!=null&&e!==""}function Xe(e,n,t={}){let{delay:r=300,initialValue:o,shouldFetch:u=On}=t,[a,c,i]=me(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=te(f,n,o===void 0?{}:{initialValue:o});return[h,{...i,query:a,setQuery:c,refetch:l}]}function re(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:re(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=re(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function Je(e){let n=S(e);return Q?S(()=>re(n()),void 0,{name:"children"}):S(()=>re(n()))}var oe=q();Ee((e,n)=>{let t=K(n,oe);t&&(t.increment(),e.finally(()=>t.decrement()))});function Ze(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function en(e,n){return I(oe,e,n)}var nn=q();Ae((e,n)=>{let t=K(n,nn);return t?(t.setError(e),!0):!1});function tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function rn(e,n){return I(nn,e,n)}var on={State:D,Computed:k,subtle:{Watcher:P,untrack:N,currentComputed:be,hasSinks:ge}};var En=Symbol.for("signal"),Cn=Symbol.for("fluixi-proxy");
1
+ "use strict";var ce=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var xn=Object.prototype.hasOwnProperty;var gn=(e,n)=>{for(var t in n)ce(e,t,{get:n[t],enumerable:!0})},Sn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of bn(n))!xn.call(e,s)&&s!==t&&ce(e,s,{get:()=>n[s],enumerable:!(r=wn(n,s))||r.enumerable});return e};var Rn=e=>Sn(ce({},"__esModule",{value:!0}),e);var Hn={};gn(Hn,{$PROXY:()=>Gn,$SIGNAL:()=>Wn,Signal:()=>mn,SuspenseContext:()=>ae,__DEV__:()=>ee,batch:()=>g,createChildOwner:()=>Me,createComputed:()=>Ke,createContext:()=>q,createDebounce:()=>cn,createDebouncedResource:()=>dn,createDebouncedSignal:()=>ge,createDeferred:()=>an,createEffect:()=>C,createErrorBoundary:()=>hn,createMemo:()=>b,createRenderEffect:()=>ze,createResource:()=>ie,createRoot:()=>_,createSelector:()=>un,createSignal:()=>f,createSuspenseBoundary:()=>fn,disposeScope:()=>Ue,flush:()=>Ye,getOwner:()=>H,getServerData:()=>re,indexArray:()=>Mn,isComponent:()=>Ze,isMemo:()=>Qe,isOwnerDisposed:()=>Fe,isProvider:()=>nn,isResource:()=>Je,isSignal:()=>ne,isSuspense:()=>en,keyArray:()=>Nn,makeArrayFlat:()=>ye,mapArray:()=>qn,nextResourceId:()=>oe,on:()=>Xe,onCleanup:()=>y,provide:()=>N,provideErrorBoundary:()=>yn,provideSuspense:()=>pn,readChildren:()=>ln,reportResourceData:()=>se,runWithOwner:()=>M,setOwner:()=>pe,setResourceDataSink:()=>sn,setResourceIdSource:()=>on,setResourceTracker:()=>tn,setServerDataGetter:()=>rn,startTransition:()=>he,trackResourcePromise:()=>te,untrack:()=>w,useContext:()=>Be,useTransition:()=>$e});module.exports=Rn(Hn);var kn="__fluixi_signal_next_state__",On=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[kn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:On,onSuspend:null,onError:null,observer:null};var ke="1.0.0-alpha.83";function _n(e){return o.observer=e,()=>{o.observer===e&&(o.observer=null)}}var A=[],Cn;function B(e){let n=o.observer;n&&n.created(e.parents===void 0?{...e,parents:A,origin:e.origin??Cn}:e)}function _e(e){return o.observer?(A.push(e),!0):!1}function Ce(){A.pop()}function Ee(e){o.observer?.ran?.(e)}function De(e,n){o.observer?.wrote?.(e,n)}function Ae(e){o.observer?.contextCreated?.(e)}function X(e,n,t){let r=o.observer;!r?.context||!A.length||r.context(A[A.length-1],e,n,t)}function V(e){o.observer?.disposed?.(e)}var En="__FLUIXI_DEVTOOLS_HOOK__",Oe=globalThis[En];if(typeof Oe?.inject=="function")try{Oe.inject({observeReactiveNodes:_n,version:ke})}catch{}function de(){return o.observer!=null}var Pe=0,Ie=1,L=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},P=class extends Q{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++,De(this,o.consumer),this.observers)for(let t of[...this.observers])t.markDirty(L);le(this)}}peek(){return this._value}},R=class extends Q{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=L;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ie&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===L)break}(this.state===L||!this._initialized)&&this.recompute(),this.state=Pe}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked,s=_e(this);o.consumer=this,o.untracked=!1;let a,u=!1,c;try{a=this._fn()}catch(l){u=!0,c=l,a=this._value}finally{o.consumer=t,o.untracked=r,s&&Ce()}let i=!this._initialized||this._threw!==u||(u?c!==this._error:!this._equals(this._value,a));if(this._initialized=!0,this._threw=u,this._error=c,this._value=a,Ee(this),i){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(L);le(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Pe;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(Ie);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)}var I=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 j(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function qe(){return o.consumer}function Ne(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Me(e){let n=G(e);return e&&(e.owned??=[]).push(n),n}function Ue(e,n=!0){W(e,n)}function Fe(e){return!!e&&e.disposed===!0}function G(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e,n){let t=Symbol(n??"context");return Ae(t),{id:t,defaultValue:e,Provider:s=>{X(t,"provide",s.value);let a=o.owner,u=G(a);(u.contexts=new Map).set(t,s.value),a&&(a.owned??=[]).push(u),o.owner=u;try{return s.children}finally{o.owner=a}}}}function Be(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id)){let t=n.contexts.get(e.id);return X(e.id,"read",t),t}n=n.parent}return X(e.id,"read",e.defaultValue),e.defaultValue}function J(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function N(e,n,t){let r=G(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function Ve(e){o.onSuspend=e}function Le(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function je(e){o.onError=e}function H(){return o.owner}function pe(e){let n=o.owner;return o.owner=e,n}function M(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function y(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function W(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)W(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 _(e){let n=G(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>W(n))}finally{o.owner=t}}function We(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Dn(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(K)))}function K(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function Ge(){o.batchDepth===0&&K()}function ve(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&K()}}var fe=class{constructor(n,t=!1){this.queued=!1;this.disposed=!1;this.owner=G(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new R(()=>{W(this.owner,!1),M(this.owner,()=>{let r=n();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),B({kind:"effect",node:this.computed,handle:this,internal:!t}),this.watcher=new I(()=>Dn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,V(this.computed),this.watcher.unwatch(this.computed),W(this.owner))}};function Z(e,n=!1){let t=new fe(e,n);return()=>t.dispose()}function An(e){return!!e&&typeof e.then=="function"}We(()=>{});var He=Symbol.for("signal"),Pn=Symbol.for("memo"),In=Symbol.for("signal-node");function f(e,n){let t=new P(e,{equals:n?.equals}),r=(()=>t.get()),s=(a=>{let u=typeof a=="function"?a(t.peek()):a;return t.set(u),Ge(),u});return Object.defineProperty(r,He,{value:!0,enumerable:!0}),Object.defineProperty(r,In,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),B({kind:"signal",node:t,handle:r,name:n?.name,set:s}),de()&&y(()=>V(t)),[r,s]}function b(e,n,t){let r=n,s=H(),a=new R(()=>M(s,()=>{try{return r=e(r)}catch(c){if(An(c))return Le(c),r;throw c}}),{equals:t?.equals}),u=(()=>a.get());return Object.defineProperty(u,He,{value:!0,enumerable:!0}),Object.defineProperty(u,Pn,{value:!0,enumerable:!0}),B({kind:"memo",node:a,handle:u,name:t?.name}),de()&&y(()=>V(a)),u}function C(e,n){let t=n;return Z(()=>{t=e(t)},!0)}function Ke(e,n){let t=n;Z(()=>{t=e(t)})}function ze(e,n){let t=n;return Z(()=>{t=e(t)})}function g(e){return ve(e)}function w(e){return j(e)}function he(e){return ve(e),Promise.resolve()}function $e(){return[()=>!1,he]}function Ye(){return K(),Promise.resolve()}function Xe(e,n,t){let r=Array.isArray(e),s,a=t?.defer??!1;return u=>{let c=r?e.map(l=>l()):e();if(a){a=!1,s=c;return}let i=j(()=>n(c,s,u));return s=c,i}}function qn(e,n,t){let r=[];return y(()=>{for(let s of r)s.dispose();r=[]}),b(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let a=new Map;for(let i of r)a.has(i.item)||a.set(i.item,i);let u=[],c=new Set;for(let i=0;i<s.length;i++){let l=s[i],v=a.get(l);if(v&&!c.has(v))v.setIndex(i),u.push(v),c.add(v);else{let d,p,h;_(m=>{h=m;let[E,U]=f(i,{name:"row index"});p=U,d=n(l,E)});let x={item:l,rendered:d,dispose:h,setIndex:p};u.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=u,u.map(i=>i.rendered)})},void 0,{name:"mapArray"})}function Nn(e,n,t,r){let s=[],a=[];return y(()=>{for(let u of a)u.dispose();s=[],a=[]}),b(()=>{let u=e()||[];return w(()=>{if(u.length===0){for(let d of a)d.dispose();return s=[],a=[],r?.fallback?r.fallback():[]}let c=new Map;for(let d=0;d<s.length;d++)c.set(s[d],a[d]);let i=[],l=[],v=new Set;for(let d=0;d<u.length;d++){let p=n(u[d]),h=c.get(p);if(h&&!v.has(p))h.setIndex(d),i.push(h);else{let x,m,E;_(U=>{E=U;let[k,F]=f(d,{name:"row index"});m=F;let z=b(D=>{let S=(e()||[])[k()];return S??D},u[d]);x=t(z,k)}),i.push({rendered:x,dispose:E,setIndex:m})}l.push(p),v.add(p)}for(let[d,p]of c)v.has(d)||p.dispose();return s=l,a=i,i.map(d=>d.rendered)})},void 0,{name:"keyArray"})}function Mn(e,n,t){let r=[];return y(()=>{for(let s of r)s.dispose();r=[]}),b(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let a=r.length,u=s.length;for(let i=a;i<u;i++){let l,v,d,p=s[i];_(h=>{d=h;let[x,m]=f(p);v=m,l=n(x,i)}),r.push({rendered:l,setItem:v,dispose:d})}for(let i=u;i<a;i++)r[i].dispose();u<a&&(r=r.slice(0,u));let c=Math.min(a,u);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})},void 0,{name:"indexArray"})}var Un=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ee=typeof process>"u"?Un:!1,Fn=Symbol.for("signal"),Bn=Symbol.for("memo"),Vn=Symbol.for("resource");function ne(e){return typeof e=="function"&&e[Fn]===!0}function Qe(e){return typeof e=="function"&&e[Bn]===!0}function Je(e){return typeof e=="function"&&e[Vn]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function nn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function ye(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?ye(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var me=null;function tn(e){me=e}function te(e){me&&me(e)}var Te=null;function rn(e){Te=e}function re(e){return Te?Te(e):void 0}var we=null;function on(e){we=e}function oe(){return we?we():void 0}var be=null;function sn(e){be=e}function se(e,n){be&&be(e,n)}function un(e,n=(t,r)=>t===r){let t=new Map;return C(()=>{let r=e();for(let[s,a]of t){let[u,c]=a,i=n(s,r);u()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[a,u]=f(!1);s=[a,u],t.set(r,s);let c=e();u(n(r,c))}return s[0]()}}function an(e,n){let[t,r]=f(e(),n);return C(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function cn(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return y(()=>{t!==void 0&&clearTimeout(t)}),r}function Ln(e){return!!e&&typeof e.then=="function"}var xe=Symbol();function ie(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let a=t.transport===!1?void 0:oe(),u=a!==void 0?re(a):void 0,c=u!==void 0,[i,l]=f(u!==void 0?u.value:t.initialValue,{equals:!1}),[v,d]=f(void 0,{equals:!1}),[p,h]=f(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,m]=f(void 0,{equals:!1}),[E,U]=f(void 0,{equals:!1}),k=xe,F=!1;C(()=>{let T=r();if(E(),T===!1||T===null||T===void 0){k=xe,g(()=>{h("unresolved"),m(void 0),d(void 0)});return}let S=F;if(F=!1,k!==xe&&T===k&&!S)return;if(k=T,c){c=!1;return}let $=!1;y(()=>$=!0);let Se=w(p),Tn=w(i),Re=Se==="ready"||Se==="refreshing";g(()=>{h(Re?"refreshing":"pending"),d(void 0)});try{let O=s(T,{value:Tn,refetching:Re});Ln(O)?(m(O),te(O),O.then(Y=>{$||(a!==void 0&&se(a,Y),g(()=>{l(()=>Y),h("ready"),m(void 0)}))},Y=>{$||g(()=>{d(Y),h("errored"),m(void 0)})})):g(()=>{l(()=>O),h("ready"),m(void 0)})}catch(O){if($)return;g(()=>{d(O),h("errored"),m(void 0)})}});let z=()=>{let T=p();return T==="pending"||T==="refreshing"},D=(()=>{let T=v();if(T)throw T;if(z()){let S=x();if(S)throw S}return i()});return Object.defineProperties(D,{state:{get:p},loading:{get:z},error:{get:v},latest:{get:i}}),Object.defineProperty(D,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(D,Symbol.for("signal"),{value:!0,enumerable:!0}),[D,{mutate:l,refetch:()=>{F=!0,U(void 0)}}]}function ge(e,n=300){let[t,r]=f(e),[s,a]=f(e),[u,c]=f(!1),i,l=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},v=()=>{l();let p=w(t);return a(()=>p),c(!1),p},d=(p=>{let h=typeof p=="function"?p(w(t)):p;return r(()=>h),c(!0),l(),i=setTimeout(v,n),h});return y(l),[s,d,{immediate:t,pending:u,flush:v,cancel:()=>{l(),c(!1)}}]}function jn(e){return e!=null&&e!==""}function dn(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:a=jn}=t,[u,c,i]=ge(e,r),l=()=>a(u())?u():!1,[v,{refetch:d}]=ie(l,n,s===void 0?{}:{initialValue:s});return[v,{...i,query:u,setQuery:c,refetch:d}]}function ue(e){if(typeof e=="function"&&!e.length){let n=e();return ne(n)?n:ue(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=ue(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function ln(e){let n=b(e);return ee?b(()=>ue(n()),void 0,{name:"children"}):b(()=>ue(n()))}var ae=q();Ve((e,n)=>{let t=J(n,ae);t&&(t.increment(),e.finally(()=>t.decrement()))});function fn(){let[e,n]=f(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function pn(e,n){return N(ae,e,n)}var vn=q();je((e,n)=>{let t=J(n,vn);return t?(t.setError(e),!0):!1});function hn(){let[e,n]=f(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function yn(e,n){return N(vn,e,n)}var mn={State:P,Computed:R,subtle:{Watcher:I,untrack:j,currentComputed:qe,hasSinks:Ne}};var Wn=Symbol.for("signal"),Gn=Symbol.for("fluixi-proxy");