@lunora/vue 1.0.0-alpha.268 → 1.0.0-alpha.269
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,7 +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
|
|
88
|
+
| `useLiveTopic` | `useLiveTopic` | Follow one declared live topic as `lastEvent` / `error` refs. |
|
|
89
89
|
| `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved. |
|
|
90
90
|
| `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map. |
|
|
91
91
|
| `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs. |
|
|
@@ -94,7 +94,7 @@ const { mutate, pending } = useMutation(api.messages.send);
|
|
|
94
94
|
| `useAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as a `ComputedRef` of discriminated events. |
|
|
95
95
|
| `useVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — refs for status/transcript/level, `startCall`/`endCall`. |
|
|
96
96
|
|
|
97
|
-
`useLiveTopic(options)` takes the `
|
|
97
|
+
`useLiveTopic(topic, options?)` takes the reference `_generated/live.ts` hands out, e.g. `useLiveTopic(live.posts.post({ postId }), { onEvent })`, as a value, a ref or a getter, so a reactive `postId` resubscribes. The stream's route is resolved against the injected `LunoraClient`, and `lastEvent` and `onEvent` are typed by the payload the topic declares. Each connection option (`shardKey`, `sessionKey`, `headers`, `withCredentials`, `retryDelay`, `maxDelayMs`) may be a plain value, a ref, or a getter. `onEvent` and `onError` are plain functions and never trigger a resubscribe. The SSE connection is shared by stream route, and it opens nothing during SSR.
|
|
98
98
|
|
|
99
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.
|
|
100
100
|
|
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,
|
|
2
|
+
import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, 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,33 +654,36 @@ 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
|
|
658
|
-
type ConnectionFields = Omit<
|
|
657
|
+
/** The connection-level fields: every {@link LiveTopicOptions} field except the two callbacks. */
|
|
658
|
+
type ConnectionFields = Omit<LiveTopicOptions, "onError" | "onEvent">;
|
|
659
659
|
/**
|
|
660
660
|
* Options for {@link useLiveTopic}. Each connection field may be a plain value, a
|
|
661
|
-
* `ref`, or a getter, so a reactive `
|
|
661
|
+
* `ref`, or a getter, so a reactive `shardKey` or `headers` re-subscribes. The callbacks
|
|
662
662
|
* are plain functions: a getter would be called by `toValue`, so they are never wrapped.
|
|
663
663
|
*/
|
|
664
|
-
type UseLiveTopicOptions = Pick<
|
|
665
|
-
interface UseLiveTopicResult {
|
|
664
|
+
type UseLiveTopicOptions<Payload = unknown> = Pick<LiveTopicOptions<Payload>, "onError" | "onEvent"> & { [K in keyof ConnectionFields]: MaybeRefOrGetter<ConnectionFields[K]>; };
|
|
665
|
+
interface UseLiveTopicResult<Payload = unknown> {
|
|
666
666
|
/** Set when the shard refuses the subscription (403, 409, 429 and similar). */
|
|
667
667
|
error: ShallowRef<LiveStreamSubscribeError | undefined>;
|
|
668
668
|
/** The last payload delivered on the topic, or `undefined` until the first event. */
|
|
669
|
-
lastEvent: ShallowRef<
|
|
669
|
+
lastEvent: ShallowRef<Payload | undefined>;
|
|
670
670
|
}
|
|
671
671
|
/**
|
|
672
672
|
* `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
|
|
673
|
-
* the calling component's effect scope.
|
|
673
|
+
* the calling component's effect scope. Pass the reference `_generated/live.ts` hands
|
|
674
|
+
* out (`live.posts.post({ postId })`), as a value, a `ref` or a getter: the stream's
|
|
675
|
+
* route is resolved against the injected `LunoraClient`, and `lastEvent` and `onEvent`
|
|
676
|
+
* are typed by the payload the topic declares.
|
|
674
677
|
*
|
|
675
678
|
* A lifecycle wrapper over `subscribeLiveTopic`: the connection is shared by URL,
|
|
676
679
|
* so several composables on one page still open one stream. It subscribes on
|
|
677
|
-
* setup, unsubscribes when the scope disposes, and resubscribes when
|
|
678
|
-
* connection field changes. Callbacks are read at call time, so they
|
|
679
|
-
* resubscribe.
|
|
680
|
+
* setup, unsubscribes when the scope disposes, and resubscribes when the reference
|
|
681
|
+
* or a reactive connection field changes. Callbacks are read at call time, so they
|
|
682
|
+
* never resubscribe.
|
|
680
683
|
*
|
|
681
684
|
* Client-only: nothing opens during SSR, and the refs stay at their initial values there.
|
|
682
685
|
*/
|
|
683
|
-
declare const useLiveTopic: (
|
|
686
|
+
declare const useLiveTopic: <Payload>(topic: MaybeRefOrGetter<LiveTopicRef<Payload>>, options?: UseLiveTopicOptions<Payload>) => UseLiveTopicResult<Payload>;
|
|
684
687
|
/**
|
|
685
688
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
686
689
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
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,
|
|
2
|
+
import { Preloaded, SubscriptionErrorCallback, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, LiveTopicOptions, LiveStreamSubscribeError, LiveTopicRef, 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,33 +654,36 @@ 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
|
|
658
|
-
type ConnectionFields = Omit<
|
|
657
|
+
/** The connection-level fields: every {@link LiveTopicOptions} field except the two callbacks. */
|
|
658
|
+
type ConnectionFields = Omit<LiveTopicOptions, "onError" | "onEvent">;
|
|
659
659
|
/**
|
|
660
660
|
* Options for {@link useLiveTopic}. Each connection field may be a plain value, a
|
|
661
|
-
* `ref`, or a getter, so a reactive `
|
|
661
|
+
* `ref`, or a getter, so a reactive `shardKey` or `headers` re-subscribes. The callbacks
|
|
662
662
|
* are plain functions: a getter would be called by `toValue`, so they are never wrapped.
|
|
663
663
|
*/
|
|
664
|
-
type UseLiveTopicOptions = Pick<
|
|
665
|
-
interface UseLiveTopicResult {
|
|
664
|
+
type UseLiveTopicOptions<Payload = unknown> = Pick<LiveTopicOptions<Payload>, "onError" | "onEvent"> & { [K in keyof ConnectionFields]: MaybeRefOrGetter<ConnectionFields[K]>; };
|
|
665
|
+
interface UseLiveTopicResult<Payload = unknown> {
|
|
666
666
|
/** Set when the shard refuses the subscription (403, 409, 429 and similar). */
|
|
667
667
|
error: ShallowRef<LiveStreamSubscribeError | undefined>;
|
|
668
668
|
/** The last payload delivered on the topic, or `undefined` until the first event. */
|
|
669
|
-
lastEvent: ShallowRef<
|
|
669
|
+
lastEvent: ShallowRef<Payload | undefined>;
|
|
670
670
|
}
|
|
671
671
|
/**
|
|
672
672
|
* `useLiveTopic` — follow one live topic of a `defineLiveStream` for the life of
|
|
673
|
-
* the calling component's effect scope.
|
|
673
|
+
* the calling component's effect scope. Pass the reference `_generated/live.ts` hands
|
|
674
|
+
* out (`live.posts.post({ postId })`), as a value, a `ref` or a getter: the stream's
|
|
675
|
+
* route is resolved against the injected `LunoraClient`, and `lastEvent` and `onEvent`
|
|
676
|
+
* are typed by the payload the topic declares.
|
|
674
677
|
*
|
|
675
678
|
* A lifecycle wrapper over `subscribeLiveTopic`: the connection is shared by URL,
|
|
676
679
|
* so several composables on one page still open one stream. It subscribes on
|
|
677
|
-
* setup, unsubscribes when the scope disposes, and resubscribes when
|
|
678
|
-
* connection field changes. Callbacks are read at call time, so they
|
|
679
|
-
* resubscribe.
|
|
680
|
+
* setup, unsubscribes when the scope disposes, and resubscribes when the reference
|
|
681
|
+
* or a reactive connection field changes. Callbacks are read at call time, so they
|
|
682
|
+
* never resubscribe.
|
|
680
683
|
*
|
|
681
684
|
* Client-only: nothing opens during SSR, and the refs stay at their initial values there.
|
|
682
685
|
*/
|
|
683
|
-
declare const useLiveTopic: (
|
|
686
|
+
declare const useLiveTopic: <Payload>(topic: MaybeRefOrGetter<LiveTopicRef<Payload>>, options?: UseLiveTopicOptions<Payload>) => UseLiveTopicResult<Payload>;
|
|
684
687
|
/**
|
|
685
688
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
686
689
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
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 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-
|
|
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-B0HA04MY.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 b,liveTopicSubscription as y}from"@lunora/client";import{stableWireKey as E}from"@lunora/wire";import{shallowRef as a,watch as w,toValue as l}from"vue";import{i as h}from"./is-browser-BEdfLJHK.mjs";import{useLunora as K}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as T}from"./scope-dispose-Mq3k4nvP.mjs";const D=i=>{const r={};for(const[o,t]of Object.entries(i))o!=="onError"&&o!=="onEvent"&&(r[o]=l(t));return r},_=(i,r={})=>{const o=a(void 0),t=a(void 0);if(h()){const p=K(),c=()=>y(p,l(i),D(r)),m=w(()=>{const{headers:u,maxDelayMs:v,retryDelay:n,sessionKey:s,topic:e,url:f,withCredentials:d}=c();return E({headers:u,maxDelayMs:v,retryDelay:n,sessionKey:s,topic:e,url:f,withCredentials:d})},(u,v,n)=>{o.value=void 0,t.value=void 0;const s=b({...c(),onError:e=>{t.value=e,r.onError?.(e)},onEvent:e=>{o.value=e,t.value=void 0,r.onEvent?.(e)}});n(s)},{immediate:!0});T(m)}return{error:t,lastEvent:o}};export{_ as useLiveTopic};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vue",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.269",
|
|
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.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.229",
|
|
58
58
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.152",
|
|
60
60
|
"@lunora/wire": "1.0.0-alpha.1",
|
|
61
61
|
"@visulima/storage-client": "1.0.9"
|
|
62
62
|
},
|
|
@@ -1 +0,0 @@
|
|
|
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};
|