@lunora/vue 1.0.0-alpha.27 → 1.0.0-alpha.271
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/LICENSE.md +6 -0
- package/README.md +23 -16
- package/dist/index.d.mts +1094 -240
- package/dist/index.d.ts +1094 -240
- package/dist/index.mjs +1 -13
- package/dist/packem_shared/AuthLoading-ZXVgXos1.mjs +1 -0
- package/dist/packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-DicHNxhB.mjs +1 -0
- package/dist/packem_shared/is-browser-BEdfLJHK.mjs +1 -0
- package/dist/packem_shared/scope-dispose-Mq3k4nvP.mjs +1 -0
- package/dist/packem_shared/subscribeToQuery-BvnA8ErG.mjs +1 -0
- package/dist/packem_shared/useAction-C4VLsh4M.mjs +1 -0
- package/dist/packem_shared/useAgent-Bp5UEoEp.mjs +1 -0
- package/dist/packem_shared/useAgentChat-CNBm2vp1.mjs +1 -0
- package/dist/packem_shared/useAgentState-DpFm2lH0.mjs +1 -0
- package/dist/packem_shared/useAgentToolEvents-CFGnBjKS.mjs +1 -0
- package/dist/packem_shared/useAuth-QDllAwZL.mjs +1 -0
- package/dist/packem_shared/useConnectionStatus-CCUbKnj2.mjs +1 -0
- package/dist/packem_shared/useFlag-xVfWC_c6.mjs +1 -0
- package/dist/packem_shared/useInfiniteQuery-Clqt_MYU.mjs +1 -0
- package/dist/packem_shared/useLiveTopic-B0HA04MY.mjs +1 -0
- package/dist/packem_shared/useMutation-D6PkaNaE.mjs +1 -0
- package/dist/packem_shared/useMutator-CO7nXlRf.mjs +1 -0
- package/dist/packem_shared/usePresence-Dpnb4kjv.mjs +1 -0
- package/dist/packem_shared/useRateLimit-zoPsflSG.mjs +1 -0
- package/dist/packem_shared/useStream-COVzNdKq.mjs +1 -0
- package/dist/packem_shared/useSubscription-cTKyOIAv.mjs +1 -0
- package/dist/packem_shared/useVoiceAgent-BEGHhbmX.mjs +1 -0
- package/dist/server.mjs +1 -1
- package/dist/upload.d.mts +2 -0
- package/dist/upload.d.ts +2 -0
- package/dist/upload.mjs +1 -0
- package/package.json +9 -8
- package/dist/packem_shared/AuthLoading-DKra8yfG.mjs +0 -29
- package/dist/packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs +0 -26
- package/dist/packem_shared/hydratePreloaded-Cnd2GmG1.mjs +0 -14
- package/dist/packem_shared/subscribeToQuery-hVYyvgOD.mjs +0 -51
- package/dist/packem_shared/useAuth-yXaaF-ro.mjs +0 -28
- package/dist/packem_shared/useConnectionStatus-DM_TOaW5.mjs +0 -20
- package/dist/packem_shared/useFlag-Diuk30zd.mjs +0 -108
- package/dist/packem_shared/useInfiniteQuery-DZMfVEuL.mjs +0 -199
- package/dist/packem_shared/useMutation-BKIwT8Jk.mjs +0 -29
- package/dist/packem_shared/useMutator-B_Ahs_ZN.mjs +0 -19
- package/dist/packem_shared/usePresence-VXq5yGzE.mjs +0 -59
- package/dist/packem_shared/useRateLimit-DlPWjcX1.mjs +0 -67
- package/dist/packem_shared/useSubscription-DHoCEXNh.mjs +0 -47
- package/dist/worker.d.mts +0 -1
- package/dist/worker.d.ts +0 -1
- package/dist/worker.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { hydratePreloaded } from './packem_shared/hydratePreloaded-Cnd2GmG1.mjs';
|
|
3
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora } from './packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
export { useAuth } from './packem_shared/useAuth-yXaaF-ro.mjs';
|
|
5
|
-
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-DM_TOaW5.mjs';
|
|
6
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-Diuk30zd.mjs';
|
|
7
|
-
export { useMutation } from './packem_shared/useMutation-BKIwT8Jk.mjs';
|
|
8
|
-
export { useMutator } from './packem_shared/useMutator-B_Ahs_ZN.mjs';
|
|
9
|
-
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-DZMfVEuL.mjs';
|
|
10
|
-
export { usePresence } from './packem_shared/usePresence-VXq5yGzE.mjs';
|
|
11
|
-
export { subscribeToQuery, useQuery } from './packem_shared/subscribeToQuery-hVYyvgOD.mjs';
|
|
12
|
-
export { useRateLimit } from './packem_shared/useRateLimit-DlPWjcX1.mjs';
|
|
13
|
-
export { useSubscription } from './packem_shared/useSubscription-DHoCEXNh.mjs';
|
|
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-Bp5UEoEp.mjs";import{useAgentChat as L}from"./packem_shared/useAgentChat-CNBm2vp1.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-DpFm2lH0.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-CFGnBjKS.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-cTKyOIAv.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{isAuthenticatedStatus as i,isLoadingStatus as d}from"@lunora/client/auth";import{defineComponent as n,computed as a}from"vue";import{useAuth as o}from"./useAuth-QDllAwZL.mjs";const m=n({name:"Authenticated",setup(s,{slots:t}){const{status:e}=o(),u=a(()=>i(e.value));return()=>u.value?t.default?.():void 0}}),h=n({name:"Unauthenticated",setup(s,{slots:t}){const{status:e}=o(),u=a(()=>e.value==="unauthenticated");return()=>u.value?t.default?.():void 0}}),l=n({name:"AuthLoading",setup(s,{slots:t}){const{status:e}=o(),u=a(()=>d(e.value));return()=>u.value?t.default?.():void 0}});export{l as AuthLoading,m as Authenticated,h as Unauthenticated};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as e}from"@lunora/errors";import{inject as t,provide as i}from"vue";const o=Symbol("lunora.client"),c=r=>({install(n){n.provide(o,r)}}),p=r=>{i(o,r)},l=()=>{const r=t(o,void 0);if(!r)throw new e("INTERNAL","useLunora(): no LunoraClient provided — call app.use(createLunora(client)) or provideLunora(client) in a parent setup().");return r};export{o as LUNORA_INJECTION_KEY,c as createLunora,p as provideLunora,l as useLunora};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as c}from"./is-browser-BEdfLJHK.mjs";import{useLunora as f}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as u}from"./scope-dispose-Mq3k4nvP.mjs";import{subscribeToQuery as d}from"./subscribeToQuery-BvnA8ErG.mjs";const v=(e,n={})=>{const o=f(),{args:t,functionPath:i,shardKey:s,value:a}=e,r=d(o,{__lunoraRef:i},t,{onError:n.onError,seed:o.identityEpoch()===0?a:void 0,shardKey:s});return c()&&u(o.onIdentityChange(()=>{r.value=void 0})),r};export{v as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=()=>globalThis.window!==void 0;export{o as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCurrentScope as e,onScopeDispose as r}from"vue";const s=(o,n)=>{e()&&r(o)};export{s as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as y}from"@lunora/client/query";import{stableWireKey as f}from"@lunora/wire";import{shallowRef as n,watch as l,toValue as i}from"vue";import{i as c}from"./is-browser-BEdfLJHK.mjs";import{useLunora as p}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as v}from"./scope-dispose-Mq3k4nvP.mjs";const R=(t,o,s,e={})=>{const r=n(e.seed);if(c()){const a=t.subscribe(o,s,u=>{r.value=u},{onError:e.onError,shardKey:e.shardKey});v(a)}return r},S=(t,o,s={})=>{const e=p(),r=n(void 0);return l(()=>f(i(o)),(a,u,m)=>{if(!c())return;r.value=void 0;const d=y(e,t,i(o),{onData:b=>{r.value=b},onError:s.onError,onReset:()=>{r.value=void 0}},{shardKey:s.shardKey});m(d)},{immediate:!0}),r};export{R as subscribeToQuery,S as useQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCallRunner as i}from"@lunora/client";import{shallowRef as n,ref as u}from"vue";import{useLunora as v}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const R=l=>{const a=v(),t=n(void 0),o=n(void 0),r=u(!1),s=()=>{t.value=void 0,o.value=void 0};return{call:i((e,c)=>a.action(l,e,c),{setError:e=>{o.value=e},setPending:e=>{r.value=e},setResult:e=>{t.value=e,o.value=void 0}}),data:t,error:o,pending:r,reset:s}};export{R as useAction};
|
|
@@ -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-cTKyOIAv.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-Bp5UEoEp.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as B}from"./useStream-COVzNdKq.mjs";import{useSubscription as E}from"./useSubscription-cTKyOIAv.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as o,toValue as n}from"vue";import{useSubscription as u}from"./useSubscription-cTKyOIAv.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computed as v,toValue as e}from"vue";import{useStream as f}from"./useStream-COVzNdKq.mjs";import{useSubscription as C}from"./useSubscription-cTKyOIAv.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{getIdentityStore as h}from"@lunora/client/auth";import{ref as u,readonly as e,onScopeDispose as m}from"vue";import{i as p}from"./is-browser-BEdfLJHK.mjs";import{useLunora as T}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const U=()=>{const t=T(),o=h(t),s=u(t.getAuthToken()),n=u(o.getUser()),r=u(o.getStatus()),c=()=>{s.value=t.getAuthToken()},i=()=>{n.value=o.getUser(),r.value=o.getStatus()},a=f=>{t.setAuthToken(f)};if(!p())return{setToken:a,status:e(r),token:e(s),user:e(n)};const g=t.onAuthTokenChange(c),k=o.subscribe(i);return m(()=>{g(),k()}),{setToken:a,status:e(r),token:e(s),user:e(n)}};export{U as useAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as r}from"vue";import{i as e}from"./is-browser-BEdfLJHK.mjs";import{useLunora as i}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as u}from"./scope-dispose-Mq3k4nvP.mjs";const p=()=>{const t=i(),o=r(t.connectionStatus());if(!e())return o;const n=t.onConnectionStatus(s=>{o.value=s});return u(n),o};export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as c,watch as b,toValue as m}from"vue";import{i as a}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as p}from"./scope-dispose-Mq3k4nvP.mjs";const _="__lunora_flags__:eval",d=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:_},i=(t,e,r)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:d(e.default)},o=>{r(o)},{onError:()=>{r(e.default)}})}catch{return()=>{}}},g=(t,e)=>{const r=l(),o=c(e);return b(()=>m(t),(n,u,s)=>{o.value=e,a()&&s(i(r,{default:e,key:n},f=>{o.value=f}))},{immediate:!0}),o},w=t=>{const e=l(),r=c(t);if(!a())return r;const o=[];for(const[n,u]of Object.entries(t))o.push(i(e,{default:u,key:n},s=>{r.value={...r.value,[n]:s}}));return p(()=>{for(const n of o)n()}),r};export{g as useFlag,w as useFlags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as _,watch as N,toValue as m,onScopeDispose as D,computed as K}from"vue";import{initialPages as B,derivePaginationStatus as O,rebalance as E,applyLoadMore as T}from"@lunora/client/pagination";import{stableWireKey as Q}from"@lunora/wire";import{i as V}from"./is-browser-BEdfLJHK.mjs";import{useLunora as W}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const M=(o,s)=>`${o}::${Q(s)}`,R=(o,s)=>({...s,paginationOpts:{cursor:o.lower,endCursor:o.upper,numItems:o.numItems}}),$=(o,s,h)=>{const x=W(),{initialNumItems:L,onError:S,shardKey:P}=h,e=_(B(L)),d=_([]),p=_(void 0);let b;const f=new Map,i=new Map,c=new Set,C=(t,a)=>{d.value=t.map(v=>{const r=M(o.__lunoraRef,R(v,a));return i.get(r)})},z=(t,a,v)=>{const r=l=>M(o.__lunoraRef,R(l,v));for(const l of a){const u=r(l);if(i.has(u))continue;const w=t.find(n=>n.lower===l.lower);if(w){const n=i.get(r(w));n&&i.set(u,n)}}},F=(t,a)=>{const v=new Set;for(const r of t)v.add(M(o.__lunoraRef,R(r,a)));for(const[r,l]of f)v.has(r)||(l(),f.delete(r),i.delete(r),c.delete(r));for(const r of t){const l=R(r,a),u=M(o.__lunoraRef,l);if(f.has(u))continue;c.add(u);const w=x.subscribe(o,l,n=>{i.set(u,n),c.delete(u),p.value=void 0;const g=m(s);if(C(e.value,g),c.size===0){const y=e.value,k=E(y,d.value);k&&(z(y,k,g),e.value=k)}},{onError:n=>{c.delete(u),p.value=n;const g=e.value,y=g.at(-1);g.length>1&&y&&!i.has(u)&&M(o.__lunoraRef,R(y,a))===u&&(e.value=g.slice(0,-1)),S?.(n)},shardKey:P});f.set(u,w)}},I=()=>{for(const t of f.values())t();f.clear(),i.clear(),c.clear()};N(()=>Q(m(s)),()=>{if(!V())return;const t=m(s);I(),e.value=B(L),d.value=[],p.value=void 0,b=void 0,t!=="skip"&&(F(e.value,t),C(e.value,t))},{immediate:!0}),N(()=>e.value,t=>{const a=m(s);b=void 0,a!=="skip"&&(F(t,a),C(t,a))}),D(I);const A=_("LoadingFirstPage");return N([()=>m(s),d],([t,a])=>{A.value=O(t==="skip",a).status},{immediate:!0}),{error:p,loadMore:t=>{const a=m(s);if(a==="skip")return;const{nextCursor:v,status:r}=O(!1,d.value);if(r!=="CanLoadMore"||v===b)return;const l=T(e.value,v,t);if(!l)return;b=v,p.value=void 0;const u=e.value.at(-1),w=l.at(-2);if(u&&w){const n=M(o.__lunoraRef,R(u,a)),g=M(o.__lunoraRef,R(w,a)),y=f.get(n);if(y&&n!==g){const k=i.get(n);k&&i.set(g,k),y(),f.delete(n),i.delete(n),c.delete(n)}}e.value=l},pageResults:d,status:A}},X=(o,s,h)=>{const{error:x,loadMore:L,pageResults:S,status:P}=$(o,s,h),e=K(()=>S.value.flatMap(p=>p?.page??[])),d=K(()=>m(s)!=="skip"&&(P.value==="LoadingFirstPage"||P.value==="LoadingMore"));return{error:x,isLoading:d,loadMore:L,results:e,status:P}},Y=(o,s,h)=>{const{initialNumItems:x}=h,{error:L,loadMore:S,pageResults:P,status:e}=$(o,s,h),d=K(()=>P.value.flatMap(c=>c?[c.page]:[])),p=K(()=>m(s)!=="skip"&&e.value==="LoadingFirstPage"),b=K(()=>e.value==="CanLoadMore"),f=K(()=>m(s)!=="skip"&&e.value==="LoadingMore");return{error:L,fetchNextPage:c=>{S(c??x)},hasNextPage:b,isFetchingNextPage:f,isLoading:p,pages:d,status:e}};export{Y as useInfiniteQuery,X as usePaginatedQuery};
|
|
@@ -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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCallRunner as v}from"@lunora/client";import{shallowRef as n,ref as c}from"vue";import{useLunora as d}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const R=a=>{const s=d(),o=n(void 0),t=n(void 0),r=c(!1),u=()=>{o.value=void 0,t.value=void 0},i=v((e,l)=>s.mutation(a,e,l),{setError:e=>{t.value=e},setPending:e=>{r.value=e},setResult:e=>{o.value=e,t.value=void 0}});return{data:o,error:t,mutate:i,pending:r,reset:u}};export{R as useMutation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMutatorRunner as c}from"@lunora/client";import{shallowRef as o,computed as i}from"vue";const d=n=>{const r=o(void 0),t=o(!1),s=i(()=>r.value!==void 0),{mutate:u,reset:a}=c(n,{setError:e=>{r.value=e},setPending:e=>{t.value=e}});return{error:r,isError:s,mutate:u,pending:t,reset:a}};export{d as useMutator};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as m}from"vue";import{i as g}from"./is-browser-BEdfLJHK.mjs";import{useLunora as h}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as w}from"./scope-dispose-Mq3k4nvP.mjs";const D=()=>{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")},S=1e4,A=(t,e)=>{const s=h(),{heartbeat:y,intervalMs:v=S,listPresent:p,shardKey:a}=e,i=e.sessionId??D(),l=m(void 0),c=m(void 0);let d=e.data,u=!1;const o=()=>{const n={roomId:t,sessionId:i,...d===void 0?{}:{data:d}};s.mutation(y,n,{shardKey:a}).catch(()=>{})},b=n=>{d=n,u&&o()};if(g()){u=!0,o();const n=setInterval(o,v),f=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",f);const I=s.acquireConnectionContext({roomId:t,sessionId:i},{shardKey:a}),U=s.subscribe(p,{roomId:t},r=>{l.value=r,c.value=void 0},{onError:r=>{c.value=r,e.onError?.(r)},shardKey:a});w(()=>{u=!1,clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",f),I(),U()})}return{error:c,present:l,sessionId:i,setData:b}};export{A as usePresence};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{evaluate as r}from"@lunora/ratelimit";import{shallowRef as k,toValue as l,watchEffect as b,onScopeDispose as A,computed as f}from"vue";const M=(o,i={})=>{const a=i.now??Date.now,p=i.tickMs??1e3;let e;const m=k(0),u=()=>{m.value+=1},t=k(r(l(o),e,{consume:!1,count:1,now:a(),reserve:!1}).status),w=b(()=>{m.value,t.value=r(l(o),e,{consume:!1,count:1,now:a(),reserve:!1}).status},{flush:"sync"});let s;const n=()=>{s!==void 0&&(clearInterval(s),s=void 0)},d=()=>{t.value.ok||s!==void 0||(s=setInterval(()=>{u(),t.value.ok&&n()},p))};A(()=>{n(),w()}),d();const h=(c=1)=>{const v=r(l(o),e,{consume:!0,count:c,now:a(),reserve:!1});return v.value!==void 0&&(e=v.value),u(),d(),v.status},I=(c=1)=>r(l(o),e,{consume:!1,count:c,now:a(),reserve:!1}).status.ok,y=()=>{e=void 0,n(),u()};return{check:I,consume:h,disabled:f(()=>!t.value.ok),ok:f(()=>t.value.ok),reset:y,retryAfter:f(()=>t.value.retryAfter)}};export{M as useRateLimit};
|
|
@@ -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 l}from"@lunora/client/query";import{LunoraError as c}from"@lunora/errors";import{stableWireKey as f}from"@lunora/wire";import{ref as v,watch as y,toValue as u,onScopeDispose as w}from"vue";import{i as h}from"./is-browser-BEdfLJHK.mjs";import{useLunora as p}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const x=(d,a,t={})=>{const n=p(),o=v(void 0),r=v(void 0);return y(()=>f(u(a)),(K,g,m)=>{const i=u(a);if(o.value=void 0,r.value=void 0,i==="skip"||!h())return;const s=l(n,d,i,{onData:e=>{o.value=e,r.value=void 0},onError:e=>{r.value=Object.assign(e.code===void 0?new Error(e.message):new c(e.code,e.message),e.why===void 0?{}:{why:e.why}),o.value=void 0,t.onError?.(e)},onReset:()=>{o.value=void 0}},{shardKey:t.shardKey});m(s)},{immediate:!0}),w(()=>{o.value=void 0,r.value=void 0}),{data:o,error:r}};export{x as useSubscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as y,onScopeDispose as N,toValue as O}from"vue";import{useLunora as P}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const M="/_lunora/ws",H="/_lunora/voice/",$=4001,I=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,B=e=>{const r=e.startsWith("agents:")?e.slice(7):e;return r.endsWith("Voice")?r.slice(0,-5):r},K=(e,r)=>{if(r===void 0||r==="")return I(e);if(r.endsWith(M))return r.slice(0,-M.length);try{return new URL(r).origin}catch{return I(e)}},q=e=>{const r=K(e.httpUrl,e.wsUrl),s=r.endsWith("/")?r.slice(0,-1):r,i=new URLSearchParams({threadKey:e.threadKey});return`${s}${H}${encodeURIComponent(e.agent)}?${i.toString()}`},J=(e,r)=>{if(r?.code===$)return new Error(`${e}: authentication token expired — refresh the credential and start a new call`)},G=(e,r,s)=>{const i=e.currentIdentity();return e.onAuthTokenChange(()=>{e.currentIdentity()!==i&&s(new Error(`${r}: the signed-in identity changed during the call — the session was ended; start a new call`))})},X=16e3,j=e=>{if(e.length===0)return 0;let r=0;for(const s of e)r+=s*s;return Math.sqrt(r/e.length)},z=(e,r)=>{const s=r/X,i=s>1?Math.floor(e.length/s):e.length,g=new ArrayBuffer(i*2),p=new DataView(g);for(let l=0;l<i;l+=1){const k=e[Math.floor(l*s)]??0,v=Math.max(-1,Math.min(1,k));p.setInt16(l*2,v<0?v*32768:v*32767,!0)}return new Uint8Array(g)},Q=async e=>{const r=globalThis,s=r.navigator?.mediaDevices?.getUserMedia.bind(r.navigator.mediaDevices),i=r.AudioContext??r.webkitAudioContext;if(!s||!i)throw new Error("useVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const g=await s({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),p=new i,l=p.createMediaStreamSource(g),k=p.createScriptProcessor(4096,1,1);let v=!1,w=!1,c=0,o=0;return k.onaudioprocess=u=>{const d=u.inputBuffer.getChannelData(0),f=v?0:j(d);if(e.onLevel(f),v)return;if(e.onAudio(z(d,p.sampleRate)),e.isTurnActive()){o=f>=e.interruptThreshold?o+1:0,o>=e.interruptChunks&&(o=0,e.onInterrupt());return}o=0;const S=d.length/p.sampleRate*1e3;if(f>=e.silenceThreshold){w=!0,c=0;return}w&&(c+=S,c>=e.silenceDurationMs&&(w=!1,c=0,e.onSilence()))},l.connect(k),k.connect(p.destination),{setMuted:u=>{v=u},stop:()=>{k.disconnect(),l.disconnect();for(const u of g.getTracks())u.stop();p.close()}}},Y=()=>{const e=globalThis,r=e.AudioContext??e.webkitAudioContext;if(!r)throw new Error("useVoiceAgent: audio playback requires AudioContext (no browser audio available)");const s=new r,i=new Set;let g=0,p=Promise.resolve(),l=0;const k=async(c,o)=>{if(o!==l)return;let u;try{u=await s.decodeAudioData(c.buffer)}catch{return}if(o!==l)return;const d=s.createBufferSource();d.buffer=u,d.connect(s.destination);const f=Math.max(s.currentTime,g);d.start(f),g=f+u.duration,i.add(d),d.onended=()=>{i.delete(d)}},v=c=>{const o=Uint8Array.from(c),u=l;p=p.then(()=>k(o,u))},w=()=>{l+=1;for(const c of i)try{c.stop()}catch{}i.clear(),g=s.currentTime};return{enqueue:v,interrupt:w,stop:()=>{w(),s.close()}}},U=1,Z=.01,ee=1200,te=.15,ne=3,ae=e=>{const{createMicrophone:r=Q,createSpeaker:s=Y,createSocket:i,interruptChunks:g=ne,interruptThreshold:p=te,silenceDurationMs:l=ee,silenceThreshold:k=Z,threadKey:v,voice:w}=e,c=P(),o=y("idle"),u=y(!1),d=y(""),f=y(""),S=y(0),C=y(!1),m=y(void 0);let a,b=!1;const _=t=>{const n=a?.socket;return n?.readyState===U?(n.send(JSON.stringify(t)),!0):!1},T=()=>{const t=a;if(a=void 0,t){t.unwatchIdentity?.(),t.microphone?.stop(),t.speaker?.stop(),t.socket.onmessage=null,t.socket.onerror=null,t.socket.onclose=null;try{t.socket.close()}catch{}}b=!1,u.value=!1,o.value="idle",S.value=0},R=T,D=t=>{const n=a;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),o.value="speaking",f.value+=t.text;break}case"assistant_done":{n&&(n.awaitingTurn=!1,n.speaking=!1),f.value=t.text,o.value="listening";break}case"error":{n&&(n.awaitingTurn=!1,n.speaking=!1),m.value=new Error(t.message),o.value="listening";break}case"interrupted":{n&&(n.awaitingTurn=!1,n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),o.value="listening";break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),u.value=!0,o.value="listening";break}case"user_transcript":{n&&(n.suppressAudio=!1),d.value=t.text,f.value="",o.value="thinking";break}}},L=t=>{const n=a;!n||n.suppressAudio||(n.speaker??=s({audioFormat:n.audioFormat}),n.speaking=!0,o.value="speaking",n.speaker.enqueue(t))},V=async()=>{if(a||b)return;b=!0,m.value=void 0,d.value="",f.value="";let t;try{const n=q({agent:B(w.__lunoraRef),httpUrl:c.url,threadKey:O(v),wsUrl:c.wsUrl}),A=(i??(h=>{const E=c.getWebSocketImpl();if(!E)throw new Error("useVoiceAgent: no WebSocket implementation available (pass createSocket explicitly)");return new E(h)}))(n);A.binaryType="arraybuffer",t={audioFormat:"mp3",microphone:void 0,socket:A,speaker:void 0,speaking:!1,awaitingTurn:!1,suppressAudio:!1,unwatchIdentity:void 0},a=t,t.unwatchIdentity=G(c,"useVoiceAgent",h=>{a===t&&(m.value=h,T())}),A.onmessage=h=>{if(typeof h.data=="string"){try{D(JSON.parse(h.data))}catch{}return}L(new Uint8Array(h.data))},A.onerror=()=>{m.value=new Error("useVoiceAgent: voice socket error")},A.onclose=h=>{if(a!==t)return;const E=J("useVoiceAgent",h);E&&(m.value=E),T()};const x=await r({interruptChunks:g,interruptThreshold:p,isTurnActive:()=>(a?.speaking??!1)||(a?.awaitingTurn??!1),onAudio:h=>{A.readyState===U&&A.send(h)},onInterrupt:()=>{_({type:"interrupt"}),a?.speaker?.interrupt(),a&&(a.awaitingTurn=!1,a.speaking=!1,a.suppressAudio=!0),o.value="listening"},onLevel:h=>{S.value=h},onSilence:()=>{_({type:"commit"}),a&&(a.awaitingTurn=!0),o.value="thinking"},silenceDurationMs:l,silenceThreshold:k});a===t?(t.microphone=x,C.value=!1,t.speaking||(o.value="listening")):x.stop()}catch(n){a===t&&(m.value=n instanceof Error?n:new Error(String(n)),T())}finally{b=!1}},F=()=>{const t=!C.value;return a?.microphone?.setMuted(t),C.value=t,t},W=t=>{_({text:t,type:"text"})&&(a&&(a.awaitingTurn=!0),o.value="thinking")};return N(T),{audioLevel:S,connected:u,endCall:R,error:m,interimTranscript:f,isMuted:C,sendText:W,startCall:V,status:o,toggleMute:F,transcript:d}};export{ae as useVoiceAgent};
|
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createServerClient as d,deserializePreloaded as l,getServerSession as a,preloadQuery as o,preloadedQueryResult as i,serializePreloaded as s}from"@lunora/client/ssr";export{d as createServerClient,l as deserializePreloaded,a as getServerSession,o as preloadQuery,i as preloadedQueryResult,s as serializePreloaded};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { RestrictionError, UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult } from '@visulima/storage-client';
|
|
2
|
+
export { type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/vue';
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { RestrictionError, UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult } from '@visulima/storage-client';
|
|
2
|
+
export { type UseChunkedRestUploadOptions, type UseChunkedRestUploadReturn, type UseFileInputOptions, type UseFileInputReturn, type UseMultipartUploadOptions, type UseMultipartUploadReturn, type UsePasteUploadOptions, type UsePasteUploadReturn, type UseTusUploadOptions, type UseTusUploadReturn, type UseUploadOptions, type UseUploadReturn, useChunkedRestUpload, useFileInput, useMultipartUpload, usePasteUpload, useTusUpload, useUpload } from '@visulima/storage-client/vue';
|
package/dist/upload.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{RestrictionError as r,UploadControl as p,UploadError as l}from"@visulima/storage-client";import{useChunkedRestUpload as t,useFileInput as u,useMultipartUpload as a,usePasteUpload as d,useTusUpload as U,useUpload as i}from"@visulima/storage-client/vue";export{r as RestrictionError,p as UploadControl,l as UploadError,t as useChunkedRestUpload,u as useFileInput,a as useMultipartUpload,d as usePasteUpload,U as useTusUpload,i as useUpload};
|
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.271",
|
|
4
4
|
"description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"types": "./dist/server.d.ts",
|
|
45
45
|
"import": "./dist/server.mjs"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
48
|
-
"types": "./dist/
|
|
49
|
-
"import": "./dist/
|
|
47
|
+
"./upload": {
|
|
48
|
+
"types": "./dist/upload.d.ts",
|
|
49
|
+
"import": "./dist/upload.mjs"
|
|
50
50
|
},
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
58
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
60
|
-
"@lunora/
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.231",
|
|
58
|
+
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.154",
|
|
60
|
+
"@lunora/wire": "1.0.0-alpha.1",
|
|
61
|
+
"@visulima/storage-client": "1.0.9"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"vue": "^3.5.0"
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { defineComponent, computed } from 'vue';
|
|
2
|
-
import { useAuth } from './useAuth-yXaaF-ro.mjs';
|
|
3
|
-
|
|
4
|
-
const Authenticated = defineComponent({
|
|
5
|
-
name: "Authenticated",
|
|
6
|
-
setup(_props, { slots }) {
|
|
7
|
-
const { token, user } = useAuth();
|
|
8
|
-
const isAuthenticated = computed(() => token.value !== null && user.value !== null);
|
|
9
|
-
return () => isAuthenticated.value ? slots.default?.() : void 0;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const Unauthenticated = defineComponent({
|
|
13
|
-
name: "Unauthenticated",
|
|
14
|
-
setup(_props, { slots }) {
|
|
15
|
-
const { token, user } = useAuth();
|
|
16
|
-
const isLoading = computed(() => token.value !== null && user.value === null);
|
|
17
|
-
return () => !isLoading.value && token.value === null ? slots.default?.() : void 0;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const AuthLoading = defineComponent({
|
|
21
|
-
name: "AuthLoading",
|
|
22
|
-
setup(_props, { slots }) {
|
|
23
|
-
const { token, user } = useAuth();
|
|
24
|
-
const isLoading = computed(() => token.value !== null && user.value === null);
|
|
25
|
-
return () => isLoading.value ? slots.default?.() : void 0;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export { AuthLoading, Authenticated, Unauthenticated };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
import { inject, provide } from 'vue';
|
|
3
|
-
|
|
4
|
-
const LUNORA_INJECTION_KEY = /* @__PURE__ */ Symbol("lunora.client");
|
|
5
|
-
const createLunora = (client) => {
|
|
6
|
-
return {
|
|
7
|
-
install(app) {
|
|
8
|
-
app.provide(LUNORA_INJECTION_KEY, client);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
const provideLunora = (client) => {
|
|
13
|
-
provide(LUNORA_INJECTION_KEY, client);
|
|
14
|
-
};
|
|
15
|
-
const useLunora = () => {
|
|
16
|
-
const client = inject(LUNORA_INJECTION_KEY, void 0);
|
|
17
|
-
if (!client) {
|
|
18
|
-
throw new LunoraError(
|
|
19
|
-
"INTERNAL",
|
|
20
|
-
"useLunora(): no LunoraClient provided — call app.use(createLunora(client)) or provideLunora(client) in a parent setup()."
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return client;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
2
|
-
import { subscribeToQuery } from './subscribeToQuery-hVYyvgOD.mjs';
|
|
3
|
-
|
|
4
|
-
const hydratePreloaded = (preloaded) => {
|
|
5
|
-
const client = useLunora();
|
|
6
|
-
const { args, functionPath, shardKey, value } = preloaded;
|
|
7
|
-
const functionReference = { __lunoraRef: functionPath };
|
|
8
|
-
return subscribeToQuery(client, functionReference, args, {
|
|
9
|
-
seed: value,
|
|
10
|
-
shardKey
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { hydratePreloaded };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { createQuerySubscription } from '@lunora/client/query';
|
|
2
|
-
import { shallowRef, getCurrentScope, onScopeDispose, watch, toValue } from 'vue';
|
|
3
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
|
|
5
|
-
const subscribeToQuery = (client, function_, args, options = {}) => {
|
|
6
|
-
const data = shallowRef(options.seed);
|
|
7
|
-
const unsubscribe = client.subscribe(
|
|
8
|
-
function_,
|
|
9
|
-
args,
|
|
10
|
-
(value) => {
|
|
11
|
-
data.value = value;
|
|
12
|
-
},
|
|
13
|
-
{ shardKey: options.shardKey }
|
|
14
|
-
);
|
|
15
|
-
if (getCurrentScope()) {
|
|
16
|
-
onScopeDispose(unsubscribe);
|
|
17
|
-
} else {
|
|
18
|
-
console.warn(
|
|
19
|
-
"[@lunora/vue] subscribeToQuery called with no active effect scope — its subscription will not be cleaned up automatically. Call it inside setup()/an effect scope, or call the returned teardown yourself."
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
const useQuery = (function_, args, options = {}) => {
|
|
25
|
-
const client = useLunora();
|
|
26
|
-
const data = shallowRef(void 0);
|
|
27
|
-
watch(
|
|
28
|
-
() => toValue(args),
|
|
29
|
-
(current, _previous, onCleanup) => {
|
|
30
|
-
const unsubscribe = createQuerySubscription(
|
|
31
|
-
client,
|
|
32
|
-
function_,
|
|
33
|
-
current,
|
|
34
|
-
{
|
|
35
|
-
onData: (value) => {
|
|
36
|
-
data.value = value;
|
|
37
|
-
},
|
|
38
|
-
onReset: () => {
|
|
39
|
-
data.value = void 0;
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{ shardKey: options.shardKey }
|
|
43
|
-
);
|
|
44
|
-
onCleanup(unsubscribe);
|
|
45
|
-
},
|
|
46
|
-
{ immediate: true }
|
|
47
|
-
);
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { subscribeToQuery, useQuery };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getIdentityStore } from '@lunora/client/auth';
|
|
2
|
-
import { ref, onScopeDispose, readonly } from 'vue';
|
|
3
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
|
-
|
|
5
|
-
const useAuth = () => {
|
|
6
|
-
const client = useLunora();
|
|
7
|
-
const store = getIdentityStore(client);
|
|
8
|
-
const tokenRef = ref(client.getAuthToken());
|
|
9
|
-
const userRef = ref(store.getUser());
|
|
10
|
-
const onTokenChange = () => {
|
|
11
|
-
tokenRef.value = client.getAuthToken();
|
|
12
|
-
};
|
|
13
|
-
const onUserChange = () => {
|
|
14
|
-
userRef.value = store.getUser();
|
|
15
|
-
};
|
|
16
|
-
const unsubToken = client.onAuthTokenChange(onTokenChange);
|
|
17
|
-
const unsubUser = store.subscribe(onUserChange);
|
|
18
|
-
onScopeDispose(() => {
|
|
19
|
-
unsubToken();
|
|
20
|
-
unsubUser();
|
|
21
|
-
});
|
|
22
|
-
const setToken = (next) => {
|
|
23
|
-
client.setAuthToken(next);
|
|
24
|
-
};
|
|
25
|
-
return { setToken, token: readonly(tokenRef), user: readonly(userRef) };
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { useAuth };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { shallowRef, getCurrentScope, onScopeDispose } from 'vue';
|
|
2
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
3
|
-
|
|
4
|
-
const useConnectionStatus = () => {
|
|
5
|
-
const client = useLunora();
|
|
6
|
-
const status = shallowRef(client.connectionStatus());
|
|
7
|
-
const unsubscribe = client.onConnectionStatus((next) => {
|
|
8
|
-
status.value = next;
|
|
9
|
-
});
|
|
10
|
-
if (getCurrentScope()) {
|
|
11
|
-
onScopeDispose(unsubscribe);
|
|
12
|
-
} else {
|
|
13
|
-
console.warn(
|
|
14
|
-
"[@lunora/vue] useConnectionStatus called with no active effect scope — its listener will not be cleaned up automatically. Call it inside setup()/an effect scope."
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
return status;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { useConnectionStatus as default };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { shallowRef, watch, toValue } from 'vue';
|
|
2
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
3
|
-
|
|
4
|
-
const compareKeys = (a, b) => {
|
|
5
|
-
if (a < b) {
|
|
6
|
-
return -1;
|
|
7
|
-
}
|
|
8
|
-
return a > b ? 1 : 0;
|
|
9
|
-
};
|
|
10
|
-
const stableStringify = (value) => {
|
|
11
|
-
if (value === void 0) {
|
|
12
|
-
return "null";
|
|
13
|
-
}
|
|
14
|
-
if (typeof value === "bigint") {
|
|
15
|
-
throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) — pass it as a string");
|
|
16
|
-
}
|
|
17
|
-
if (value === null || typeof value !== "object") {
|
|
18
|
-
return JSON.stringify(value);
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(value)) {
|
|
21
|
-
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
22
|
-
}
|
|
23
|
-
const proto = Object.getPrototypeOf(value);
|
|
24
|
-
if (proto !== null && proto !== Object.prototype) {
|
|
25
|
-
const name = value.constructor?.name ?? "value";
|
|
26
|
-
throw new TypeError(
|
|
27
|
-
`stableStringify: cannot use a ${name} in a cache key (query/subscription/shape args) — only plain objects, arrays, and JSON primitives are supported`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const record = value;
|
|
31
|
-
const keys = Object.keys(record).toSorted(compareKeys);
|
|
32
|
-
const parts = [];
|
|
33
|
-
for (const key of keys) {
|
|
34
|
-
const raw = record[key];
|
|
35
|
-
if (raw === void 0) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
|
|
39
|
-
}
|
|
40
|
-
return `{${parts.join(",")}}`;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const FLAGS_EVAL_PATH = "__lunora_flags__:eval";
|
|
44
|
-
const flagKind = (value) => {
|
|
45
|
-
const kind = typeof value;
|
|
46
|
-
if (kind === "boolean" || kind === "number" || kind === "string") {
|
|
47
|
-
return kind;
|
|
48
|
-
}
|
|
49
|
-
return "object";
|
|
50
|
-
};
|
|
51
|
-
const flagsReference = { __lunoraRef: FLAGS_EVAL_PATH };
|
|
52
|
-
const serializeContext = (context) => context === void 0 ? "" : stableStringify(context);
|
|
53
|
-
const useFlag = (key, defaultValue, context) => {
|
|
54
|
-
const client = useLunora();
|
|
55
|
-
const type = flagKind(defaultValue);
|
|
56
|
-
const value = shallowRef(defaultValue);
|
|
57
|
-
watch(
|
|
58
|
-
() => `${toValue(key)}\0${serializeContext(toValue(context))}`,
|
|
59
|
-
(_serialized, _previous, onCleanup) => {
|
|
60
|
-
const currentKey = toValue(key);
|
|
61
|
-
const currentContext = toValue(context);
|
|
62
|
-
value.value = defaultValue;
|
|
63
|
-
let unsubscribe;
|
|
64
|
-
try {
|
|
65
|
-
unsubscribe = client.subscribe(flagsReference, { context: currentContext, default: defaultValue, key: currentKey, type }, (next) => {
|
|
66
|
-
value.value = next;
|
|
67
|
-
});
|
|
68
|
-
} catch {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
onCleanup(unsubscribe);
|
|
72
|
-
},
|
|
73
|
-
{ immediate: true }
|
|
74
|
-
);
|
|
75
|
-
return value;
|
|
76
|
-
};
|
|
77
|
-
const useFlags = (flags, context) => {
|
|
78
|
-
const client = useLunora();
|
|
79
|
-
const values = shallowRef(flags);
|
|
80
|
-
const spec = stableStringify(flags);
|
|
81
|
-
watch(
|
|
82
|
-
() => `${spec}\0${serializeContext(toValue(context))}`,
|
|
83
|
-
(_serialized, _previous, onCleanup) => {
|
|
84
|
-
const currentContext = toValue(context);
|
|
85
|
-
values.value = flags;
|
|
86
|
-
const unsubscribes = [];
|
|
87
|
-
for (const [key, defaultValue] of Object.entries(flags)) {
|
|
88
|
-
try {
|
|
89
|
-
unsubscribes.push(
|
|
90
|
-
client.subscribe(flagsReference, { context: currentContext, default: defaultValue, key, type: flagKind(defaultValue) }, (next) => {
|
|
91
|
-
values.value = { ...values.value, [key]: next };
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
} catch {
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
onCleanup(() => {
|
|
98
|
-
for (const unsubscribe of unsubscribes) {
|
|
99
|
-
unsubscribe();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
{ immediate: true }
|
|
104
|
-
);
|
|
105
|
-
return values;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export { useFlag, useFlags };
|