@lunora/vue 1.0.0-alpha.267 → 1.0.0-alpha.268

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -85,6 +85,7 @@ const { mutate, pending } = useMutation(api.messages.send);
85
85
  | `useInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `usePaginatedQuery`. |
86
86
  | `useAuth` | `useAuth` | Reactive auth: readonly `token`/`user`/`status` refs plus `setToken`. |
87
87
  | `usePresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members `ShallowRef`. |
88
+ | `useLiveTopic` | `useLiveTopic` | Follow one `defineLiveStream` topic as `lastEvent` / `error` refs. |
88
89
  | `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved. |
89
90
  | `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map. |
90
91
  | `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs. |
@@ -93,6 +94,8 @@ const { mutate, pending } = useMutation(api.messages.send);
93
94
  | `useAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as a `ComputedRef` of discriminated events. |
94
95
  | `useVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — refs for status/transcript/level, `startCall`/`endCall`. |
95
96
 
97
+ `useLiveTopic(options)` takes the `subscribeLiveTopic` options. Each connection field may be a plain value, a ref, or a getter, so a reactive `topic` resubscribes when it changes. `onEvent` and `onError` are plain functions and never trigger a resubscribe. The SSE connection is shared by `url`, and it opens nothing during SSR.
98
+
96
99
  `useVoiceAgent` opens nothing until `startCall()` — that call is what requests the microphone, so it must run from a user gesture. `endCall()` releases the socket, the mic tracks and the Web Audio graph, and `onScopeDispose` runs it for you on unmount.
97
100
 
98
101
  ## Related
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
2
+ import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, SubscribeLiveTopicOptions, LiveStreamSubscribeError, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
3
3
  export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe, User } from '@lunora/client';
4
4
  import { AuthStatus } from '@lunora/client/auth';
5
5
  import { PaginationStatus } from '@lunora/client/pagination';
@@ -654,6 +654,33 @@ declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defa
654
654
  * composable's lifetime, so nothing here is reactive.
655
655
  */
656
656
  declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
657
+ /** The connection-level fields: every `subscribeLiveTopic` option except the two callbacks. */
658
+ type ConnectionFields = Omit<SubscribeLiveTopicOptions, "onError" | "onEvent">;
659
+ /**
660
+ * Options for {@link useLiveTopic}. Each connection field may be a plain value, a
661
+ * `ref`, or a getter, so a reactive `topic` or `url` re-subscribes. The callbacks
662
+ * are plain functions: a getter would be called by `toValue`, so they are never wrapped.
663
+ */
664
+ type UseLiveTopicOptions = Pick<SubscribeLiveTopicOptions, "onError" | "onEvent"> & { [K in keyof ConnectionFields]: MaybeRefOrGetter<ConnectionFields[K]>; };
665
+ interface UseLiveTopicResult {
666
+ /** Set when the shard refuses the subscription (403, 409, 429 and similar). */
667
+ error: ShallowRef<LiveStreamSubscribeError | undefined>;
668
+ /** The last payload delivered on the topic, or `undefined` until the first event. */
669
+ lastEvent: ShallowRef<unknown>;
670
+ }
671
+ /**
672
+ * `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
673
+ * the calling component's effect scope.
674
+ *
675
+ * A lifecycle wrapper over `subscribeLiveTopic`: the connection is shared by URL,
676
+ * so several composables on one page still open one stream. It subscribes on
677
+ * setup, unsubscribes when the scope disposes, and resubscribes when a reactive
678
+ * connection field changes. Callbacks are read at call time, so they never
679
+ * resubscribe.
680
+ *
681
+ * Client-only: nothing opens during SSR, and the refs stay at their initial values there.
682
+ */
683
+ declare const useLiveTopic: (options: UseLiveTopicOptions) => UseLiveTopicResult;
657
684
  /**
658
685
  * The reactive handle returned by {@link useMutation} — the Vue counterpart to
659
686
  * React's `useMutation`, re-expressed with refs. The surface is identical across
@@ -1181,7 +1208,7 @@ export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type Age
1181
1208
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1182
1209
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1183
1210
  */
1184
- LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus,
1211
+ LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus,
1185
1212
  /**
1186
1213
  * `@lunora/vue` — the Vue adapter for Lunora.
1187
1214
  *
@@ -1219,7 +1246,7 @@ createLunora, hydratePreloaded,
1219
1246
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1220
1247
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1221
1248
  */
1222
- provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1249
+ provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLiveTopic,
1223
1250
  /**
1224
1251
  * `@lunora/vue` — the Vue adapter for Lunora.
1225
1252
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
2
- import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
2
+ import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, SubscribeLiveTopicOptions, LiveStreamSubscribeError, MutationCallOptions, MutatorHandle, SubscriptionError } from '@lunora/client';
3
3
  export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, Unsubscribe, User } from '@lunora/client';
4
4
  import { AuthStatus } from '@lunora/client/auth';
5
5
  import { PaginationStatus } from '@lunora/client/pagination';
@@ -654,6 +654,33 @@ declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defa
654
654
  * composable's lifetime, so nothing here is reactive.
655
655
  */
656
656
  declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
657
+ /** The connection-level fields: every `subscribeLiveTopic` option except the two callbacks. */
658
+ type ConnectionFields = Omit<SubscribeLiveTopicOptions, "onError" | "onEvent">;
659
+ /**
660
+ * Options for {@link useLiveTopic}. Each connection field may be a plain value, a
661
+ * `ref`, or a getter, so a reactive `topic` or `url` re-subscribes. The callbacks
662
+ * are plain functions: a getter would be called by `toValue`, so they are never wrapped.
663
+ */
664
+ type UseLiveTopicOptions = Pick<SubscribeLiveTopicOptions, "onError" | "onEvent"> & { [K in keyof ConnectionFields]: MaybeRefOrGetter<ConnectionFields[K]>; };
665
+ interface UseLiveTopicResult {
666
+ /** Set when the shard refuses the subscription (403, 409, 429 and similar). */
667
+ error: ShallowRef<LiveStreamSubscribeError | undefined>;
668
+ /** The last payload delivered on the topic, or `undefined` until the first event. */
669
+ lastEvent: ShallowRef<unknown>;
670
+ }
671
+ /**
672
+ * `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
673
+ * the calling component's effect scope.
674
+ *
675
+ * A lifecycle wrapper over `subscribeLiveTopic`: the connection is shared by URL,
676
+ * so several composables on one page still open one stream. It subscribes on
677
+ * setup, unsubscribes when the scope disposes, and resubscribes when a reactive
678
+ * connection field changes. Callbacks are read at call time, so they never
679
+ * resubscribe.
680
+ *
681
+ * Client-only: nothing opens during SSR, and the refs stay at their initial values there.
682
+ */
683
+ declare const useLiveTopic: (options: UseLiveTopicOptions) => UseLiveTopicResult;
657
684
  /**
658
685
  * The reactive handle returned by {@link useMutation} — the Vue counterpart to
659
686
  * React's `useMutation`, re-expressed with refs. The surface is identical across
@@ -1181,7 +1208,7 @@ export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type Age
1181
1208
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1182
1209
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1183
1210
  */
1184
- LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus,
1211
+ LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAgentApi, type UseAgentChatApi, type UseAgentChatOptions, type UseAgentChatResult, type UseAgentOptions, type UseAgentResult, type UseAgentStateApi, type UseAgentStateOptions, type UseAgentStateResult, type UseAgentToolEventsApi, type UseAgentToolEventsOptions, type UseAgentToolEventsResult, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseLiveTopicOptions, type UseLiveTopicResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseStreamOptions, type UseStreamResult, type UseStreamStatus, type UseSubscriptionResult, type UseVoiceAgentOptions, type UseVoiceAgentResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus,
1185
1212
  /**
1186
1213
  * `@lunora/vue` — the Vue adapter for Lunora.
1187
1214
  *
@@ -1219,7 +1246,7 @@ createLunora, hydratePreloaded,
1219
1246
  * composition (Lunora mounted inside Nitro) is `@lunora/nuxt`, not this
1220
1247
  * package — see [Bring your framework](/docs/frameworks/bring-your-framework).
1221
1248
  */
1222
- provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery,
1249
+ provideLunora, subscribeToQuery, useAction, useAgent, useAgentChat, useAgentState, useAgentToolEvents, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLiveTopic,
1223
1250
  /**
1224
1251
  * `@lunora/vue` — the Vue adapter for Lunora.
1225
1252
  *
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-ZXVgXos1.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-DicHNxhB.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-CH-s5x_8.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-EOyd090T.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-DYGMiZea.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-CXaLK5pE.mjs";import{useAuth as b}from"./packem_shared/useAuth-QDllAwZL.mjs";import{default as E}from"./packem_shared/useConnectionStatus-CCUbKnj2.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-Clqt_MYU.mjs";import{usePresence as J}from"./packem_shared/usePresence-Dpnb4kjv.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-BvnA8ErG.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-BMJ1kYm8.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-ZXVgXos1.mjs";import{hydratePreloaded as p}from"./packem_shared/hydratePreloaded-DicHNxhB.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as n,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as c}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-CH-s5x_8.mjs";import{useAgentChat as L}from"./packem_shared/useAgentChat-EOyd090T.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-DYGMiZea.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-CXaLK5pE.mjs";import{useAuth as T}from"./packem_shared/useAuth-QDllAwZL.mjs";import{default as v}from"./packem_shared/useConnectionStatus-CCUbKnj2.mjs";import{useFlag as E,useFlags as I}from"./packem_shared/useFlag-xVfWC_c6.mjs";import{useLiveTopic as P}from"./packem_shared/useLiveTopic-Bcz34mfU.mjs";import{useMutation as M}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as R}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as _,usePaginatedQuery as J}from"./packem_shared/useInfiniteQuery-Clqt_MYU.mjs";import{usePresence as V}from"./packem_shared/usePresence-Dpnb4kjv.mjs";import{subscribeToQuery as j,useQuery as k}from"./packem_shared/subscribeToQuery-BvnA8ErG.mjs";import{useRateLimit as w}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as B}from"./packem_shared/useStream-COVzNdKq.mjs";import{useSubscription as G}from"./packem_shared/useSubscription-BMJ1kYm8.mjs";import{useVoiceAgent as W}from"./packem_shared/useVoiceAgent-BEGHhbmX.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,p as hydratePreloaded,n as provideLunora,j as subscribeToQuery,c as useAction,d as useAgent,L as useAgentChat,l as useAgentState,Q as useAgentToolEvents,T as useAuth,v as useConnectionStatus,E as useFlag,I as useFlags,_ as useInfiniteQuery,P as useLiveTopic,x as useLunora,M as useMutation,R as useMutator,J as usePaginatedQuery,V as usePresence,k as useQuery,w as useRateLimit,B as useStream,G as useSubscription,W as useVoiceAgent};
@@ -0,0 +1 @@
1
+ import{subscribeLiveTopic as u}from"@lunora/client";import{stableWireKey as a}from"@lunora/wire";import{shallowRef as i,watch as l,toValue as m}from"vue";import{i as f}from"./is-browser-BEdfLJHK.mjs";import{o as p}from"./scope-dispose-Mq3k4nvP.mjs";const s=e=>{const r={};for(const[o,t]of Object.entries(e))o!=="onError"&&o!=="onEvent"&&(r[o]=m(t));return r},L=e=>{const r=i(void 0),o=i(void 0);if(f()){const t=l(()=>a(s(e)),(d,E,c)=>{r.value=void 0,o.value=void 0;const v=u({...s(e),onError:n=>{o.value=n,e.onError?.(n)},onEvent:n=>{r.value=n,o.value=void 0,e.onEvent?.(n)}});c(v)},{immediate:!0});p(t)}return{error:o,lastEvent:r}};export{L as useLiveTopic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/vue",
3
- "version": "1.0.0-alpha.267",
3
+ "version": "1.0.0-alpha.268",
4
4
  "description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -54,9 +54,9 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@lunora/client": "1.0.0-alpha.227",
57
+ "@lunora/client": "1.0.0-alpha.228",
58
58
  "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
59
- "@lunora/ratelimit": "1.0.0-alpha.150",
59
+ "@lunora/ratelimit": "1.0.0-alpha.151",
60
60
  "@lunora/wire": "1.0.0-alpha.1",
61
61
  "@visulima/storage-client": "1.0.9"
62
62
  },