@lunora/vue 1.0.0-alpha.114 → 1.0.0-alpha.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -187,6 +187,12 @@ interface UseAgentOptions {
187
187
  * no-op.
188
188
  */
189
189
  cancel?: FunctionReference<"mutation">;
190
+ /**
191
+ * Called when the live thread subscription reports an error (a session
192
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
193
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
194
+ */
195
+ onError?: SubscriptionErrorCallback;
190
196
  /**
191
197
  * The app mutation that starts (or continues) a run — a thin wrapper over
192
198
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -204,6 +210,8 @@ interface UseAgentResult {
204
210
  * no-op when no `cancel` mutation was supplied or no run is in flight.
205
211
  */
206
212
  cancel: () => Promise<void>;
213
+ /** The live thread subscription's last error, or `undefined`. */
214
+ error: Ref<Error | undefined>;
207
215
  /** `true` while a `run` invocation is in flight. */
208
216
  pending: Readonly<Ref<boolean>>;
209
217
  /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
@@ -342,6 +350,12 @@ interface UseAgentChatOptions {
342
350
  cancel?: FunctionReference<"mutation">;
343
351
  /** History depth forwarded to `agents:agentMessages`. */
344
352
  limit?: number;
353
+ /**
354
+ * Called when the live history or thread subscription reports an error (a
355
+ * session expiry, an RLS denial). Without it — and without reading `error` —
356
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
357
+ */
358
+ onError?: SubscriptionErrorCallback;
345
359
  /**
346
360
  * The app mutation that starts (or continues) a run — a thin wrapper over
347
361
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -367,6 +381,8 @@ interface UseAgentChatResult {
367
381
  * no-op when no `cancel` mutation was supplied or no run is in flight.
368
382
  */
369
383
  cancel: () => Promise<void>;
384
+ /** The history or thread subscription's last error, or `undefined`. */
385
+ error: ComputedRef<Error | undefined>;
370
386
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
371
387
  messages: ComputedRef<ReadonlyArray<AgentChatMessage>>;
372
388
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
@@ -793,6 +809,12 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
793
809
  intervalMs?: number;
794
810
  /** The `api.*` reference for the presence listPresent query. */
795
811
  listPresent: L;
812
+ /**
813
+ * Called when the `listPresent` subscription reports an error (a session
814
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
815
+ * failure is invisible and `present` is cleared until a later frame arrives.
816
+ */
817
+ onError?: SubscriptionErrorCallback;
796
818
  /**
797
819
  * Stable id for this presence row. Defaults to a fresh per-mount id.
798
820
  * Pass a user/connection id to control deduping across tabs.
@@ -802,6 +824,8 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
802
824
  shardKey?: string;
803
825
  }
804
826
  interface UsePresenceResult<L extends ListPresentReference> {
827
+ /** The `listPresent` subscription's last error, or `undefined`. */
828
+ error: ShallowRef<SubscriptionError | undefined>;
805
829
  /** The present members for the room. `undefined` until the first push. */
806
830
  present: ShallowRef<ReturnOf<L> | undefined>;
807
831
  /** This mount's session id (generated when not supplied). */
@@ -922,6 +946,7 @@ interface UseStreamOptions {
922
946
  *
923
947
  * `args` may be a plain value, `ref`, or getter; resolving it to `"skip"` keeps
924
948
  * the composable mounted without opening a stream (mirrors `useSubscription`).
949
+ * Nothing opens during SSR either — the stream attaches after hydration.
925
950
  * The Vue counterpart to React's `useStream`, re-expressed with refs.
926
951
  */
927
952
  declare const useStream: <F extends FunctionReference<"stream">>(function_: F, args: MaybeRefOrGetter<"skip" | ArgsOf<F>>, options?: UseStreamOptions) => UseStreamResult<ReturnOf<F>>;
package/dist/index.d.ts CHANGED
@@ -187,6 +187,12 @@ interface UseAgentOptions {
187
187
  * no-op.
188
188
  */
189
189
  cancel?: FunctionReference<"mutation">;
190
+ /**
191
+ * Called when the live thread subscription reports an error (a session
192
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
193
+ * failure is invisible and `thread` / `status` are cleared until a later frame arrives.
194
+ */
195
+ onError?: SubscriptionErrorCallback;
190
196
  /**
191
197
  * The app mutation that starts (or continues) a run — a thin wrapper over
192
198
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -204,6 +210,8 @@ interface UseAgentResult {
204
210
  * no-op when no `cancel` mutation was supplied or no run is in flight.
205
211
  */
206
212
  cancel: () => Promise<void>;
213
+ /** The live thread subscription's last error, or `undefined`. */
214
+ error: Ref<Error | undefined>;
207
215
  /** `true` while a `run` invocation is in flight. */
208
216
  pending: Readonly<Ref<boolean>>;
209
217
  /** Start (or continue) a run with a user message; extra args merge over `runArgs`. */
@@ -342,6 +350,12 @@ interface UseAgentChatOptions {
342
350
  cancel?: FunctionReference<"mutation">;
343
351
  /** History depth forwarded to `agents:agentMessages`. */
344
352
  limit?: number;
353
+ /**
354
+ * Called when the live history or thread subscription reports an error (a
355
+ * session expiry, an RLS denial). Without it — and without reading `error` —
356
+ * such a failure is invisible and `messages` / `status` are cleared until a later frame arrives.
357
+ */
358
+ onError?: SubscriptionErrorCallback;
345
359
  /**
346
360
  * The app mutation that starts (or continues) a run — a thin wrapper over
347
361
  * `ctx.agents.<name>.run(...)`. Called with `{ threadKey, input }` merged with
@@ -367,6 +381,8 @@ interface UseAgentChatResult {
367
381
  * no-op when no `cancel` mutation was supplied or no run is in flight.
368
382
  */
369
383
  cancel: () => Promise<void>;
384
+ /** The history or thread subscription's last error, or `undefined`. */
385
+ error: ComputedRef<Error | undefined>;
370
386
  /** Durable thread history (oldest first) plus any un-acknowledged optimistic user turns. */
371
387
  messages: ComputedRef<ReadonlyArray<AgentChatMessage>>;
372
388
  /** Reject a paused human-in-the-loop tool call (optionally with a reason). */
@@ -793,6 +809,12 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
793
809
  intervalMs?: number;
794
810
  /** The `api.*` reference for the presence listPresent query. */
795
811
  listPresent: L;
812
+ /**
813
+ * Called when the `listPresent` subscription reports an error (a session
814
+ * expiry, an RLS denial). Without it — and without reading `error` — such a
815
+ * failure is invisible and `present` is cleared until a later frame arrives.
816
+ */
817
+ onError?: SubscriptionErrorCallback;
796
818
  /**
797
819
  * Stable id for this presence row. Defaults to a fresh per-mount id.
798
820
  * Pass a user/connection id to control deduping across tabs.
@@ -802,6 +824,8 @@ interface UsePresenceOptions<H extends HeartbeatReference, L extends ListPresent
802
824
  shardKey?: string;
803
825
  }
804
826
  interface UsePresenceResult<L extends ListPresentReference> {
827
+ /** The `listPresent` subscription's last error, or `undefined`. */
828
+ error: ShallowRef<SubscriptionError | undefined>;
805
829
  /** The present members for the room. `undefined` until the first push. */
806
830
  present: ShallowRef<ReturnOf<L> | undefined>;
807
831
  /** This mount's session id (generated when not supplied). */
@@ -922,6 +946,7 @@ interface UseStreamOptions {
922
946
  *
923
947
  * `args` may be a plain value, `ref`, or getter; resolving it to `"skip"` keeps
924
948
  * the composable mounted without opening a stream (mirrors `useSubscription`).
949
+ * Nothing opens during SSR either — the stream attaches after hydration.
925
950
  * The Vue counterpart to React's `useStream`, re-expressed with refs.
926
951
  */
927
952
  declare const useStream: <F extends FunctionReference<"stream">>(function_: F, args: MaybeRefOrGetter<"skip" | ArgsOf<F>>, options?: UseStreamOptions) => UseStreamResult<ReturnOf<F>>;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-BpzZkPH4.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as A}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-By6FSLfF.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-Dv_y3vQH.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-BYx1l9vy.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-BMwcZ2G9.mjs";import{useAuth as b}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as E}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as N,useFlags as P}from"./packem_shared/useFlag-xVfWC_c6.mjs";import{useMutation as v}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as M}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as R,usePaginatedQuery as U}from"./packem_shared/useInfiniteQuery-2KHGc4Ss.mjs";import{usePresence as J}from"./packem_shared/usePresence-BOs1lDlC.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-G5w094pU.mjs";import{useRateLimit as k}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as w}from"./packem_shared/useStream-Ca4Rkw4p.mjs";import{useSubscription as B}from"./packem_shared/useSubscription-yGJRK0w-.mjs";import{useVoiceAgent as G}from"./packem_shared/useVoiceAgent-BEGHhbmX.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,V as subscribeToQuery,A as useAction,d as useAgent,h as useAgentChat,l as useAgentState,Q as useAgentToolEvents,b as useAuth,E as useConnectionStatus,N as useFlag,P as useFlags,R as useInfiniteQuery,x as useLunora,v as useMutation,M as useMutator,U as usePaginatedQuery,J as usePresence,Y as useQuery,k as useRateLimit,w as useStream,B as useSubscription,G as useVoiceAgent};
1
+ import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-BpzZkPH4.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as A}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-BLhUb7TW.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-D9dYI4Pq.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-eXsZU41P.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-CXb7Vtcn.mjs";import{useAuth as b}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as E}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as N,useFlags as P}from"./packem_shared/useFlag-xVfWC_c6.mjs";import{useMutation as v}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as M}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as R,usePaginatedQuery as U}from"./packem_shared/useInfiniteQuery-PpVC-DWP.mjs";import{usePresence as J}from"./packem_shared/usePresence-CQ8zOCOI.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-G5w094pU.mjs";import{useRateLimit as k}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as w}from"./packem_shared/useStream-COVzNdKq.mjs";import{useSubscription as B}from"./packem_shared/useSubscription-ImlDfQGg.mjs";import{useVoiceAgent as G}from"./packem_shared/useVoiceAgent-BEGHhbmX.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,V as subscribeToQuery,A as useAction,d as useAgent,h as useAgentChat,l as useAgentState,Q as useAgentToolEvents,b as useAuth,E as useConnectionStatus,N as useFlag,P as useFlags,R as useInfiniteQuery,x as useLunora,v as useMutation,M as useMutator,U as usePaginatedQuery,J as usePresence,Y as useQuery,k as useRateLimit,w as useStream,B as useSubscription,G as useVoiceAgent};
@@ -0,0 +1 @@
1
+ import{computed as c,toValue as a}from"vue";import{useMutation as s}from"./useMutation-D6PkaNaE.mjs";import{useSubscription as M}from"./useSubscription-ImlDfQGg.mjs";const R={__lunoraRef:""},T=u=>{const{api:i,cancel:r,onError:d,run:l,runArgs:m,threadKey:e}=u,o=s(l),p=s(r??R),{data:f,error:g}=M(i.agents.agentThread,()=>({key:a(e)}),{onError:d}),n=c(()=>f.value),h=c(()=>n.value?.status),y=async(t,v)=>{await o.mutate({input:t,threadKey:a(e),...m,...v})};return{cancel:async()=>{const t=n.value?.instanceId;r===void 0||t===void 0||await p.mutate({instanceId:t,threadKey:a(e)})},error:g,pending:o.pending,run:y,status:h,thread:n}};export{R as NO_MUTATION_REF,T as useAgent};
@@ -0,0 +1 @@
1
+ import{reconcileOptimistic as A,maxSeq as w}from"@lunora/client";import{computed as c,ref as V,watch as $,toValue as a}from"vue";import{NO_MUTATION_REF as z}from"./useAgent-BLhUb7TW.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as B}from"./useStream-COVzNdKq.mjs";import{useSubscription as E}from"./useSubscription-ImlDfQGg.mjs";const G={__lunoraRef:""},tt=R=>{const{api:u,cancel:v,limit:p,onError:h,send:k,sendArgs:x,stream:f,threadKey:n}=R,{data:I,error:M}=E(u.agents.agentMessages,()=>{const t=a(n);return p===void 0?{key:t}:{key:t,limit:p}},{onError:h}),{data:S,error:b}=E(u.agents.agentThread,()=>({key:a(n)}),{onError:h}),_=c(()=>M.value??b.value),K=f===void 0?"skip":()=>({key:a(n)}),{chunks:T}=B(f??G,K),j=m(k),q=m(v??z),O=m(u.agents.agentResolveApproval),o=V([]);let g=0;$(()=>a(n),()=>{o.value=[]});const l=c(()=>S.value),C=c(()=>l.value?.status),i=c(()=>I.value??[]),D=c(()=>{const t=i.value,r=A(o.value,t);if(r.length===0)return t;const e=w(t);return[...t,...r.map((s,d)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+d}))]}),N=c(()=>{const t=a(n),r=i.value.filter(e=>e.role==="assistant").length;return T.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=r).map(e=>e.text).join("")}),F=async(t,r)=>{const e=g;g+=1;const s=w(i.value);o.value=[...A(o.value,i.value),{content:t,id:e,maxDurableSeqAtSend:s}];try{await j.mutate({input:t,threadKey:a(n),...x,...r})}catch(d){throw o.value=o.value.filter(U=>U.id!==e),d}},y=async(t,r,e)=>{const s=l.value?.instanceId;if(s===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await O.mutate({decision:t,instanceId:s,threadKey:a(n),toolCallId:r,...e===void 0?{}:{note:e}})};return{approve:async(t,r)=>y("approve",t,r),cancel:async()=>{const t=l.value?.instanceId;v===void 0||t===void 0||await q.mutate({instanceId:t,threadKey:a(n)})},error:_,messages:D,reject:async(t,r)=>y("reject",t,r),send:F,status:C,streamingText:N}};export{tt as useAgentChat};
@@ -1 +1 @@
1
- import{computed as o,toValue as n}from"vue";import{useSubscription as u}from"./useSubscription-yGJRK0w-.mjs";const m=t=>{const{data:e,error:r}=u(t.api.agents.agentState,()=>({key:n(t.threadKey)})),a=o(()=>e.value);return{error:r,state:a}};export{m as useAgentState};
1
+ import{computed as o,toValue as n}from"vue";import{useSubscription as u}from"./useSubscription-ImlDfQGg.mjs";const m=t=>{const{data:e,error:r}=u(t.api.agents.agentState,()=>({key:n(t.threadKey)})),a=o(()=>e.value);return{error:r,state:a}};export{m as useAgentState};
@@ -1 +1 @@
1
- import{computed as v,toValue as e}from"vue";import{useStream as f}from"./useStream-Ca4Rkw4p.mjs";import{useSubscription as C}from"./useSubscription-yGJRK0w-.mjs";const y={__lunoraRef:""},I=[],N=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},h=t=>{const{api:l,limit:a,stream:u,threadKey:n}=t,d=()=>{const r=e(n);return a===void 0?{key:r}:{key:r,limit:a}},{data:p}=C(l.agents.agentMessages,d),s=u===void 0?"skip":()=>({key:e(n)}),{chunks:c}=f(u??y,s);return{events:v(()=>{const r=e(n),i=(p.value??I).flatMap(o=>N(o)??[]);for(const o of c.value)o.kind==="progress"&&o.threadKey===r&&i.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return i})}};export{h as useAgentToolEvents};
1
+ import{computed as v,toValue as e}from"vue";import{useStream as f}from"./useStream-COVzNdKq.mjs";import{useSubscription as C}from"./useSubscription-ImlDfQGg.mjs";const y={__lunoraRef:""},I=[],N=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(l=>({input:l.input,seq:t.seq,toolCallId:l.id,toolName:l.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},h=t=>{const{api:l,limit:a,stream:u,threadKey:n}=t,d=()=>{const r=e(n);return a===void 0?{key:r}:{key:r,limit:a}},{data:p}=C(l.agents.agentMessages,d),s=u===void 0?"skip":()=>({key:e(n)}),{chunks:c}=f(u??y,s);return{events:v(()=>{const r=e(n),i=(p.value??I).flatMap(o=>N(o)??[]);for(const o of c.value)o.kind==="progress"&&o.threadKey===r&&i.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return i})}};export{h as useAgentToolEvents};
@@ -0,0 +1 @@
1
+ import{shallowRef as _,watch as v,toValue as O,onScopeDispose as q,computed as E}from"vue";import{initialPages as $,derivePaginationStatus as D,rebalance as z,applyLoadMore as G}from"@lunora/client/pagination";import{i as H}from"./is-browser-BEdfLJHK.mjs";import{useLunora as X}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const Y=/["\\\u0000-\u001F\uD800-\uDFFF]/,T=e=>Y.test(e)?JSON.stringify(e):`"${e}"`,x=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return T(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let o="[";for(let n=0;n<e.length;n++)n>0&&(o+=","),o+=x(e[n]);return o+"]"}const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const o=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${o} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const y=e,f=Object.keys(y).sort();let a="{",t=!0;for(const o of f){const n=y[o];n!==void 0&&(t?t=!1:a+=",",a+=T(o),a+=":",a+=x(n))}return a+"}"},F=e=>{let r="";for(let f=0;f<e.length;f+=32768)r+=String.fromCharCode(...e.subarray(f,f+32768));return btoa(r)},d="$lunora.wire$",U=64,J="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},S=(e,r=0)=>{if(r>U)throw new RangeError(`wire-codec: value nesting exceeds the ${U}-level limit`);if(e===void 0)return[d,"undefined"];if(e===null)return null;const y=typeof e;if(y==="bigint")return[d,"bigint",e.toString()];if(y==="number"){const t=e;return Number.isNaN(t)?[d,"nan"]:t===1/0?[d,"inf"]:t===-1/0?[d,"-inf"]:t}if(y!=="object")return e;if(e instanceof Date)return[d,"date",S(e.getTime(),r+1)];if(e instanceof Error){const t=e,o={};for(const c of Object.keys(t)){if(t[c]===void 0)continue;const b=S(t[c],r+1);c===J?Object.defineProperty(o,c,{configurable:!0,enumerable:!0,value:b,writable:!0}):o[c]=b}const n=[d,"error",t.name,t.message,o];return t.cause!==void 0&&n.push(S(t.cause,r+1)),n}if(e instanceof URL)return[d,"url",e.href];if(e instanceof Map)return[d,"map",[...e.entries()].map(([t,o])=>[S(t,r+1),S(o,r+1)])];if(e instanceof Set)return[d,"set",[...e].map(t=>S(t,r+1))];if(e instanceof ArrayBuffer)return[d,"bytes",F(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,o=t.constructor.name,n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return o==="Uint8Array"?[d,"bytes",F(n)]:[d,"bytes",F(n),o]}if(Array.isArray(e)){const t=e.map(o=>S(o,r+1));return t.length>0&&t[0]===d?[d,"arr",t]:t}if(!Z(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const f=e,a={};for(const t of Object.keys(f)){const o=f[t];if(o===void 0)continue;const n=S(o,r+1);t===J?Object.defineProperty(a,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):a[t]=n}return a},W=e=>x(S(e)),M=(e,r)=>`${e}::${W(r)}`,R=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),Q=(e,r,y)=>{const f=X(),{initialNumItems:a,onError:t,shardKey:o}=y,n=_($(a)),c=_([]),b=_(void 0);let j;const k=new Map,m=new Map,w=new Set,K=(s,i)=>{c.value=s.map(P=>{const l=M(e.__lunoraRef,R(P,i));return m.get(l)})},V=(s,i,P)=>{const l=g=>M(e.__lunoraRef,R(g,P));for(const g of i){const p=l(g);if(m.has(p))continue;const A=s.find(u=>u.lower===g.lower);if(A){const u=m.get(l(A));u&&m.set(p,u)}}},C=(s,i)=>{const P=new Set;for(const l of s)P.add(M(e.__lunoraRef,R(l,i)));for(const[l,g]of k)P.has(l)||(g(),k.delete(l),m.delete(l),w.delete(l));for(const l of s){const g=R(l,i),p=M(e.__lunoraRef,g);if(k.has(p))continue;w.add(p);const A=f.subscribe(e,g,u=>{m.set(p,u),w.delete(p),b.value=void 0;const h=O(r);if(K(n.value,h),w.size===0){const N=n.value,L=z(N,c.value);L&&(V(N,L,h),n.value=L)}},{onError:u=>{w.delete(p),b.value=u;const h=n.value,N=h.at(-1);h.length>1&&N&&!m.has(p)&&M(e.__lunoraRef,R(N,i))===p&&(n.value=h.slice(0,-1)),t?.(u)},shardKey:o});k.set(p,A)}},I=()=>{for(const s of k.values())s();k.clear(),m.clear(),w.clear()};v(()=>W(O(r)),()=>{if(!H())return;const s=O(r);I(),n.value=$(a),c.value=[],b.value=void 0,j=void 0,s!=="skip"&&(C(n.value,s),K(n.value,s))},{immediate:!0}),v(()=>n.value,s=>{const i=O(r);j=void 0,i!=="skip"&&(C(s,i),K(s,i))}),q(I);const B=_("LoadingFirstPage");return v([()=>O(r),c],([s,i])=>{B.value=D(s==="skip",i).status},{immediate:!0}),{error:b,loadMore:s=>{const i=O(r);if(i==="skip")return;const{nextCursor:P,status:l}=D(!1,c.value);if(l!=="CanLoadMore"||P===j)return;const g=G(n.value,P,s);if(!g)return;j=P,b.value=void 0;const p=n.value.at(-1),A=g.at(-2);if(p&&A){const u=M(e.__lunoraRef,R(p,i)),h=M(e.__lunoraRef,R(A,i)),N=k.get(u);if(N&&u!==h){const L=m.get(u);L&&m.set(h,L),N(),k.delete(u),m.delete(u),w.delete(u)}}n.value=g},pageResults:c,status:B}},se=(e,r,y)=>{const{error:f,loadMore:a,pageResults:t,status:o}=Q(e,r,y),n=E(()=>t.value.flatMap(b=>b?.page??[])),c=E(()=>O(r)!=="skip"&&(o.value==="LoadingFirstPage"||o.value==="LoadingMore"));return{error:f,isLoading:c,loadMore:a,results:n,status:o}},ie=(e,r,y)=>{const{initialNumItems:f}=y,{error:a,loadMore:t,pageResults:o,status:n}=Q(e,r,y),c=E(()=>o.value.flatMap(w=>w?[w.page]:[])),b=E(()=>O(r)!=="skip"&&n.value==="LoadingFirstPage"),j=E(()=>n.value==="CanLoadMore"),k=E(()=>O(r)!=="skip"&&n.value==="LoadingMore");return{error:a,fetchNextPage:w=>{t(w??f)},hasNextPage:j,isFetchingNextPage:k,isLoading:b,pages:c,status:n}};export{ie as useInfiniteQuery,se as usePaginatedQuery};
@@ -0,0 +1 @@
1
+ import{shallowRef as f}from"vue";import{i as U}from"./is-browser-BEdfLJHK.mjs";import{useLunora as g}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as h}from"./scope-dispose-Mq3k4nvP.mjs";const w=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},D=1e4,V=(t,e)=>{const s=g(),{heartbeat:m,intervalMs:y=D,listPresent:v,shardKey:a}=e,i=e.sessionId??w(),u=f(void 0),c=f(void 0);let d=e.data;const o=()=>{const n={roomId:t,sessionId:i,...d===void 0?{}:{data:d}};s.mutation(m,n,{shardKey:a}).catch(()=>{})},p=n=>{d=n,o()};if(U()){o();const n=setInterval(o,y),l=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",l);const b=s.acquireConnectionContext({roomId:t,sessionId:i},{shardKey:a}),I=s.subscribe(v,{roomId:t},r=>{u.value=r,c.value=void 0},{onError:r=>{c.value=r,e.onError?.(r)},shardKey:a});h(()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",l),b(),I()})}return{error:c,present:u,sessionId:i,setData:p}};export{V as usePresence};
@@ -0,0 +1 @@
1
+ import{ref as s,watch as p,toValue as b,onScopeDispose as w}from"vue";import{i as y}from"./is-browser-BEdfLJHK.mjs";import{useLunora as k}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const K=(m,v,c={})=>{const d=k(),a=s([]),u=s(void 0),e=s("idle");let t;const i=()=>{t?.()};return p(()=>b(v),(l,x,h)=>{if(a.value=[],u.value=void 0,l==="skip"||!y()){e.value="idle";return}e.value="streaming";let o=!0;const f=d.stream(m,l,{durable:c.durable,maxBuffer:c.maxBuffer,shardKey:c.shardKey}),n=()=>{f.cancel()};t=n,(async()=>{try{for await(const r of f){if(!o)return;a.value=[...a.value,r]}o&&(e.value="complete")}catch(r){if(!o)return;u.value=r instanceof Error?r:new Error(String(r)),e.value="error"}})().catch(()=>{}),h(()=>{o=!1,n(),t===n&&(t=void 0)})},{immediate:!0}),w(()=>{i()}),{cancel:i,chunks:a,error:u,status:e}};export{K as useStream};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as m}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{ref as v,watch as c,toValue as f,onScopeDispose as p}from"vue";import{i as w}from"./is-browser-BEdfLJHK.mjs";import{useLunora as h}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const k=(t,u,a={})=>{const d=h(),o=v(void 0),r=v(void 0);return c(()=>f(u),(i,y,n)=>{if(o.value=void 0,r.value=void 0,i==="skip"||!w())return;const s=m(d,t,i,{onData:e=>{o.value=e,r.value=void 0},onError:e=>{r.value=e.code===void 0?new Error(e.message):new l(e.code,e.message),o.value=void 0,a.onError?.(e)},onReset:()=>{o.value=void 0}},{shardKey:a.shardKey});n(s)},{immediate:!0}),p(()=>{o.value=void 0,r.value=void 0}),{data:o,error:r}};export{k as useSubscription};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vue",
3
- "version": "1.0.0-alpha.114",
3
+ "version": "1.0.0-alpha.116",
4
4
  "description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,7 +54,7 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.79",
57
+ "@lunora/client": "1.0.0-alpha.80",
58
58
  "@lunora/errors": "1.0.0-alpha.32",
59
59
  "@lunora/ratelimit": "1.0.0-alpha.39",
60
60
  "@visulima/storage-client": "1.0.2"
@@ -1 +0,0 @@
1
- import{computed as o,toValue as a}from"vue";import{useMutation as s}from"./useMutation-D6PkaNaE.mjs";import{useSubscription as y}from"./useSubscription-yGJRK0w-.mjs";const v={__lunoraRef:""},I=u=>{const{api:i,cancel:c,run:d,runArgs:l,threadKey:e}=u,r=s(d),m=s(c??v),{data:p}=y(i.agents.agentThread,()=>({key:a(e)})),n=o(()=>p.value),f=o(()=>n.value?.status),g=async(t,h)=>{await r.mutate({input:t,threadKey:a(e),...l,...h})};return{cancel:async()=>{const t=n.value?.instanceId;c===void 0||t===void 0||await m.mutate({instanceId:t,threadKey:a(e)})},pending:r.pending,run:g,status:f,thread:n}};export{v as NO_MUTATION_REF,I as useAgent};
@@ -1 +0,0 @@
1
- import{reconcileOptimistic as y,maxSeq as A}from"@lunora/client";import{ref as D,watch as N,toValue as s,computed as c}from"vue";import{NO_MUTATION_REF as F}from"./useAgent-By6FSLfF.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as U}from"./useStream-Ca4Rkw4p.mjs";import{useSubscription as w}from"./useSubscription-yGJRK0w-.mjs";const V={__lunoraRef:""},W=R=>{const{api:u,cancel:v,limit:p,send:k,sendArgs:x,stream:h,threadKey:a}=R,{data:I}=w(u.agents.agentMessages,()=>{const t=s(a);return p===void 0?{key:t}:{key:t,limit:p}}),{data:M}=w(u.agents.agentThread,()=>({key:s(a)})),S=h===void 0?"skip":()=>({key:s(a)}),{chunks:_}=U(h??V,S),b=m(k),K=m(v??F),T=m(u.agents.agentResolveApproval),r=D([]);let f=0;N(()=>s(a),()=>{r.value=[]});const l=c(()=>M.value),j=c(()=>l.value?.status),i=c(()=>I.value??[]),q=c(()=>{const t=i.value,n=y(r.value,t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((o,d)=>({content:o.content,optimistic:!0,role:"user",seq:e+1+d}))]}),E=c(()=>{const t=s(a),n=i.value.filter(e=>e.role==="assistant").length;return _.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),O=async(t,n)=>{const e=f;f+=1;const o=A(i.value);r.value=[...y(r.value,i.value),{content:t,id:e,maxDurableSeqAtSend:o}];try{await b.mutate({input:t,threadKey:s(a),...x,...n})}catch(d){throw r.value=r.value.filter(C=>C.id!==e),d}},g=async(t,n,e)=>{const o=l.value?.instanceId;if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await T.mutate({decision:t,instanceId:o,threadKey:s(a),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>g("approve",t,n),cancel:async()=>{const t=l.value?.instanceId;v===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:s(a)})},messages:q,reject:async(t,n)=>g("reject",t,n),send:O,status:j,streamingText:E}};export{W as useAgentChat};
@@ -1 +0,0 @@
1
- import{shallowRef as _,watch as v,toValue as L,onScopeDispose as q,computed as E}from"vue";import{initialPages as $,derivePaginationStatus as D,rebalance as z,applyLoadMore as G}from"@lunora/client/pagination";import{i as H}from"./is-browser-BEdfLJHK.mjs";import{useLunora as X}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const Y=/["\\\u0000-\u001F\uD800-\uDFFF]/,T=e=>Y.test(e)?JSON.stringify(e):`"${e}"`,x=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return T(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let o="[";for(let r=0;r<e.length;r++)r>0&&(o+=","),o+=x(e[r]);return o+"]"}const n=Object.getPrototypeOf(e);if(n!==null&&n!==Object.prototype){const o=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${o} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const y=e,f=Object.keys(y).sort();let a="{",t=!0;for(const o of f){const r=y[o];r!==void 0&&(t?t=!1:a+=",",a+=T(o),a+=":",a+=x(r))}return a+"}"},F=e=>{let n="";for(let f=0;f<e.length;f+=32768)n+=String.fromCharCode(...e.subarray(f,f+32768));return btoa(n)},d="$lunora.wire$",U=64,J="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},S=(e,n=0)=>{if(n>U)throw new RangeError(`wire-codec: value nesting exceeds the ${U}-level limit`);if(e===void 0)return[d,"undefined"];if(e===null)return null;const y=typeof e;if(y==="bigint")return[d,"bigint",e.toString()];if(y==="number"){const t=e;return Number.isNaN(t)?[d,"nan"]:t===1/0?[d,"inf"]:t===-1/0?[d,"-inf"]:t}if(y!=="object")return e;if(e instanceof Date)return[d,"date",S(e.getTime(),n+1)];if(e instanceof Error){const t=e,o={};for(const c of Object.keys(t)){if(t[c]===void 0)continue;const b=S(t[c],n+1);c===J?Object.defineProperty(o,c,{configurable:!0,enumerable:!0,value:b,writable:!0}):o[c]=b}const r=[d,"error",t.name,t.message,o];return t.cause!==void 0&&r.push(S(t.cause,n+1)),r}if(e instanceof URL)return[d,"url",e.href];if(e instanceof Map)return[d,"map",[...e.entries()].map(([t,o])=>[S(t,n+1),S(o,n+1)])];if(e instanceof Set)return[d,"set",[...e].map(t=>S(t,n+1))];if(e instanceof ArrayBuffer)return[d,"bytes",F(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,o=t.constructor.name,r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return o==="Uint8Array"?[d,"bytes",F(r)]:[d,"bytes",F(r),o]}if(Array.isArray(e)){const t=e.map(o=>S(o,n+1));return t.length>0&&t[0]===d?[d,"arr",t]:t}if(!Z(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const f=e,a={};for(const t of Object.keys(f)){const o=f[t];if(o===void 0)continue;const r=S(o,n+1);t===J?Object.defineProperty(a,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):a[t]=r}return a},W=e=>x(S(e)),A=(e,n)=>`${e}::${W(n)}`,M=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),Q=(e,n,y)=>{const f=X(),{initialNumItems:a,onError:t,shardKey:o}=y,r=_($(a)),c=_([]),b=_(void 0);let R;const P=new Map,m=new Map,w=new Set,K=(s,i)=>{c.value=s.map(h=>{const l=A(e.__lunoraRef,M(h,i));return m.get(l)})},V=(s,i,h)=>{const l=p=>A(e.__lunoraRef,M(p,h));for(const p of i){const g=l(p);if(m.has(g))continue;const N=s.find(u=>u.lower===p.lower);if(N){const u=m.get(l(N));u&&m.set(g,u)}}},C=(s,i)=>{const h=new Set;for(const l of s)h.add(A(e.__lunoraRef,M(l,i)));for(const[l,p]of P)h.has(l)||(p(),P.delete(l),m.delete(l),w.delete(l));for(const l of s){const p=M(l,i),g=A(e.__lunoraRef,p);if(P.has(g))continue;w.add(g);const N=f.subscribe(e,p,u=>{m.set(g,u),w.delete(g),b.value=void 0;const k=L(n);if(K(r.value,k),w.size===0){const O=r.value,j=z(O,c.value);j&&(V(O,j,k),r.value=j)}},{onError:u=>{w.delete(g),b.value=u;const k=r.value,O=k.at(-1);k.length>1&&O&&!m.has(g)&&A(e.__lunoraRef,M(O,i))===g&&(r.value=k.slice(0,-1)),t?.(u)},shardKey:o});P.set(g,N)}},I=()=>{for(const s of P.values())s();P.clear(),m.clear(),w.clear()};v(()=>W(L(n)),()=>{if(!H())return;const s=L(n);I(),r.value=$(a),c.value=[],b.value=void 0,R=void 0,s!=="skip"&&(C(r.value,s),K(r.value,s))},{immediate:!0}),v(()=>r.value,s=>{const i=L(n);R=void 0,i!=="skip"&&(C(s,i),K(s,i))}),q(I);const B=_("LoadingFirstPage");return v([()=>L(n),c],([s,i])=>{B.value=D(s==="skip",i).status},{immediate:!0}),{error:b,loadMore:s=>{const i=L(n);if(i==="skip")return;const{nextCursor:h,status:l}=D(!1,c.value);if(l!=="CanLoadMore"||h===R)return;const p=G(r.value,h,s);if(!p)return;R=h,b.value=void 0;const g=r.value.at(-1),N=p.at(-2);if(g&&N){const u=A(e.__lunoraRef,M(g,i)),k=A(e.__lunoraRef,M(N,i)),O=P.get(u);if(O&&u!==k){const j=m.get(u);j&&m.set(k,j),O(),P.delete(u),m.delete(u),w.delete(u)}}r.value=p},pageResults:c,status:B}},se=(e,n,y)=>{const{error:f,loadMore:a,pageResults:t,status:o}=Q(e,n,y),r=E(()=>t.value.flatMap(b=>b?.page??[])),c=E(()=>o.value==="LoadingFirstPage"||o.value==="LoadingMore");return{error:f,isLoading:c,loadMore:a,results:r,status:o}},ie=(e,n,y)=>{const{initialNumItems:f}=y,{error:a,loadMore:t,pageResults:o,status:r}=Q(e,n,y),c=E(()=>o.value.flatMap(w=>w?[w.page]:[])),b=E(()=>r.value==="LoadingFirstPage"),R=E(()=>r.value==="CanLoadMore"),P=E(()=>r.value==="LoadingMore");return{error:a,fetchNextPage:w=>{t(w??f)},hasNextPage:R,isFetchingNextPage:P,isLoading:b,pages:c,status:r}};export{ie as useInfiniteQuery,se as usePaginatedQuery};
@@ -1 +0,0 @@
1
- import{shallowRef as b}from"vue";import{i as I}from"./is-browser-BEdfLJHK.mjs";import{useLunora as U}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as g}from"./scope-dispose-Mq3k4nvP.mjs";const h=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const e=crypto.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}}throw new Error("randomSessionId: no Web Crypto available — a session id needs crypto.randomUUID or crypto.getRandomValues")},w=1e4,R=(e,t)=>{const r=U(),{heartbeat:u,intervalMs:f=w,listPresent:l,shardKey:s}=t,i=t.sessionId??h(),c=b(void 0);let a=t.data;const o=()=>{const n={roomId:e,sessionId:i,...a===void 0?{}:{data:a}};r.mutation(u,n,{shardKey:s}).catch(()=>{})},m=n=>{a=n,o()};if(I()){o();const n=setInterval(o,f),d=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",d);const p=r.acquireConnectionContext({roomId:e,sessionId:i},{shardKey:s}),y=r.subscribe(l,{roomId:e},v=>{c.value=v},{shardKey:s});g(()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",d),p(),y()})}return{present:c,sessionId:i,setData:m}};export{R as usePresence};
@@ -1 +0,0 @@
1
- import{ref as l,watch as p,toValue as b,onScopeDispose as y}from"vue";import{useLunora as k}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const S=(v,m,o={})=>{const d=k(),a=l([]),u=l(void 0),e=l("idle");let t;const s=()=>{t?.()};return p(()=>b(m),(i,w,h)=>{if(a.value=[],u.value=void 0,i==="skip"){e.value="idle";return}e.value="streaming";let c=!0;const f=d.stream(v,i,{durable:o.durable,maxBuffer:o.maxBuffer,shardKey:o.shardKey}),n=()=>{f.cancel()};t=n,(async()=>{try{for await(const r of f){if(!c)return;a.value=[...a.value,r]}c&&(e.value="complete")}catch(r){if(!c)return;u.value=r instanceof Error?r:new Error(String(r)),e.value="error"}})().catch(()=>{}),h(()=>{c=!1,n(),t===n&&(t=void 0)})},{immediate:!0}),y(()=>{s()}),{cancel:s,chunks:a,error:u,status:e}};export{S as useStream};
@@ -1 +0,0 @@
1
- import{createQuerySubscription as m}from"@lunora/client/query";import{LunoraError as l}from"@lunora/errors";import{ref as i,watch as c,toValue as p,onScopeDispose as f}from"vue";import{i as w}from"./is-browser-BEdfLJHK.mjs";import{useLunora as h}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const g=(t,u,v={})=>{const s=h(),e=i(void 0),r=i(void 0);return c(()=>p(u),(a,y,d)=>{if(e.value=void 0,r.value=void 0,a==="skip"||!w())return;const n=m(s,t,a,{onData:o=>{e.value=o,r.value=void 0},onError:o=>{r.value=o.code===void 0?new Error(o.message):new l(o.code,o.message),e.value=void 0},onReset:()=>{e.value=void 0}},{shardKey:v.shardKey});d(n)},{immediate:!0}),f(()=>{e.value=void 0,r.value=void 0}),{data:e,error:r}};export{g as useSubscription};