@lunora/vue 1.0.0-alpha.13 → 1.0.0-alpha.130
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 +20 -16
- package/dist/index.d.mts +1047 -240
- package/dist/index.d.ts +1047 -240
- package/dist/index.mjs +1 -13
- package/dist/packem_shared/AuthLoading-Dp-20UXt.mjs +1 -0
- package/dist/packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs +1 -0
- package/dist/packem_shared/hydratePreloaded-BpzZkPH4.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-G5w094pU.mjs +1 -0
- package/dist/packem_shared/useAction-C4VLsh4M.mjs +1 -0
- package/dist/packem_shared/useAgent-BLhUb7TW.mjs +1 -0
- package/dist/packem_shared/useAgentChat-D9dYI4Pq.mjs +1 -0
- package/dist/packem_shared/useAgentState-eXsZU41P.mjs +1 -0
- package/dist/packem_shared/useAgentToolEvents-CXb7Vtcn.mjs +1 -0
- package/dist/packem_shared/useAuth-axmO2A7B.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-T4qCkGfy.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-CQ8zOCOI.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-ImlDfQGg.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 +8 -7
- package/dist/packem_shared/AuthLoading-_6-uOycE.mjs +0 -29
- package/dist/packem_shared/LUNORA_INJECTION_KEY-DtFXLDQ_.mjs +0 -22
- package/dist/packem_shared/hydratePreloaded-rVY68iFv.mjs +0 -14
- package/dist/packem_shared/subscribeToQuery-Cv5YL-SI.mjs +0 -51
- package/dist/packem_shared/useAuth-C2aEzXXH.mjs +0 -28
- package/dist/packem_shared/useConnectionStatus-CDgduQYe.mjs +0 -20
- package/dist/packem_shared/useFlag-yTJu5_q7.mjs +0 -98
- package/dist/packem_shared/useInfiniteQuery-CEfbw7Nw.mjs +0 -199
- package/dist/packem_shared/useMutation-DWubV5pv.mjs +0 -29
- package/dist/packem_shared/useMutator-B_Ahs_ZN.mjs +0 -19
- package/dist/packem_shared/usePresence-BeN5xaZM.mjs +0 -59
- package/dist/packem_shared/useRateLimit-DlPWjcX1.mjs +0 -67
- package/dist/packem_shared/useSubscription-Ol0AZFUv.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-rVY68iFv.mjs';
|
|
3
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora } from './packem_shared/LUNORA_INJECTION_KEY-DtFXLDQ_.mjs';
|
|
4
|
-
export { useAuth } from './packem_shared/useAuth-C2aEzXXH.mjs';
|
|
5
|
-
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-CDgduQYe.mjs';
|
|
6
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-yTJu5_q7.mjs';
|
|
7
|
-
export { useMutation } from './packem_shared/useMutation-DWubV5pv.mjs';
|
|
8
|
-
export { useMutator } from './packem_shared/useMutator-B_Ahs_ZN.mjs';
|
|
9
|
-
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-CEfbw7Nw.mjs';
|
|
10
|
-
export { usePresence } from './packem_shared/usePresence-BeN5xaZM.mjs';
|
|
11
|
-
export { subscribeToQuery, useQuery } from './packem_shared/subscribeToQuery-Cv5YL-SI.mjs';
|
|
12
|
-
export { useRateLimit } from './packem_shared/useRateLimit-DlPWjcX1.mjs';
|
|
13
|
-
export { useSubscription } from './packem_shared/useSubscription-Ol0AZFUv.mjs';
|
|
1
|
+
import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-Dp-20UXt.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-axmO2A7B.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-T4qCkGfy.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{defineComponent as o,computed as a}from"vue";import{useAuth as l}from"./useAuth-axmO2A7B.mjs";const r=o({name:"Authenticated",setup(s,{slots:t}){const{token:e,user:n}=l(),u=a(()=>e.value!==null&&n.value!==null);return()=>u.value?t.default?.():void 0}}),c=o({name:"Unauthenticated",setup(s,{slots:t}){const{token:e,user:n}=l(),u=a(()=>e.value!==null&&n.value===null);return()=>!u.value&&e.value===null?t.default?.():void 0}}),p=o({name:"AuthLoading",setup(s,{slots:t}){const{token:e,user:n}=l(),u=a(()=>e.value!==null&&n.value===null);return()=>u.value?t.default?.():void 0}});export{p as AuthLoading,r as Authenticated,c 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{useLunora as u}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{subscribeToQuery as a}from"./subscribeToQuery-G5w094pU.mjs";const l=(r,e={})=>{const o=u(),{args:n,functionPath:t,shardKey:c,value:s}=r;return a(o,{__lunoraRef:t},n,{onError:e.onError,seed:s,shardKey:c})};export{l 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 b}from"@lunora/client/query";import{shallowRef as i,watch as f,toValue as l}from"vue";import{i as n}from"./is-browser-BEdfLJHK.mjs";import{useLunora as v}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as p}from"./scope-dispose-Mq3k4nvP.mjs";const Q=(s,t,o,e={})=>{const r=i(e.seed);if(n()){const a=s.subscribe(t,o,u=>{r.value=u},{onError:e.onError,shardKey:e.shardKey});p(a)}return r},D=(s,t,o={})=>{const e=v(),r=i(void 0);return f(()=>l(t),(a,u,c)=>{if(!n())return;r.value=void 0;const m=b(e,s,a,{onData:d=>{r.value=d},onError:o.onError,onReset:()=>{r.value=void 0}},{shardKey:o.shardKey});c(m)},{immediate:!0}),r};export{Q as subscribeToQuery,D 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-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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -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-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{getIdentityStore as g}from"@lunora/client/auth";import{ref as u,readonly as o,onScopeDispose as h}from"vue";import{i as m}from"./is-browser-BEdfLJHK.mjs";import{useLunora as p}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const U=()=>{const e=p(),t=g(e),n=u(e.getAuthToken()),s=u(t.getUser()),c=()=>{n.value=e.getAuthToken()},i=()=>{s.value=t.getUser()},r=f=>{e.setAuthToken(f)};if(!m())return{setToken:r,token:o(n),user:o(s)};const k=e.onAuthTokenChange(c),a=t.subscribe(i);return h(()=>{k(),a()}),{setToken:r,token:o(n),user:o(s)}};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 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},h=(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",h(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=h(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",String(t.name),String(t.message),o];return t.cause!==void 0&&n.push(h(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])=>[h(t,r+1),h(o,r+1)])];if(e instanceof Set)return[d,"set",[...e].map(t=>h(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=>h(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=h(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(h(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 S=O(r);if(K(n.value,S),w.size===0){const N=n.value,L=z(N,c.value);L&&(V(N,L,S),n.value=L)}},{onError:u=>{w.delete(p),b.value=u;const S=n.value,N=S.at(-1);S.length>1&&N&&!m.has(p)&&M(e.__lunoraRef,R(N,i))===p&&(n.value=S.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)),S=M(e.__lunoraRef,R(A,i)),N=k.get(u);if(N&&u!==S){const L=m.get(u);L&&m.set(S,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{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 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{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 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};
|
|
@@ -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.130",
|
|
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,9 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
58
|
-
"@lunora/
|
|
59
|
-
"@lunora/
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.94",
|
|
58
|
+
"@lunora/errors": "1.0.0-alpha.35",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.50",
|
|
60
|
+
"@visulima/storage-client": "1.0.3"
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"vue": "^3.5.0"
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { defineComponent, computed } from 'vue';
|
|
2
|
-
import { useAuth } from './useAuth-C2aEzXXH.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,22 +0,0 @@
|
|
|
1
|
-
import { inject, provide } from 'vue';
|
|
2
|
-
|
|
3
|
-
const LUNORA_INJECTION_KEY = /* @__PURE__ */ Symbol("lunora.client");
|
|
4
|
-
const createLunora = (client) => {
|
|
5
|
-
return {
|
|
6
|
-
install(app) {
|
|
7
|
-
app.provide(LUNORA_INJECTION_KEY, client);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
const provideLunora = (client) => {
|
|
12
|
-
provide(LUNORA_INJECTION_KEY, client);
|
|
13
|
-
};
|
|
14
|
-
const useLunora = () => {
|
|
15
|
-
const client = inject(LUNORA_INJECTION_KEY, void 0);
|
|
16
|
-
if (!client) {
|
|
17
|
-
throw new Error("useLunora(): no LunoraClient provided — call app.use(createLunora(client)) or provideLunora(client) in a parent setup().");
|
|
18
|
-
}
|
|
19
|
-
return client;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DtFXLDQ_.mjs';
|
|
2
|
-
import { subscribeToQuery } from './subscribeToQuery-Cv5YL-SI.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-DtFXLDQ_.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-DtFXLDQ_.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-DtFXLDQ_.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,98 +0,0 @@
|
|
|
1
|
-
import { shallowRef, watch, toValue } from 'vue';
|
|
2
|
-
import { useLunora } from './LUNORA_INJECTION_KEY-DtFXLDQ_.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 (value === null || typeof value !== "object") {
|
|
15
|
-
return JSON.stringify(value);
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
19
|
-
}
|
|
20
|
-
const record = value;
|
|
21
|
-
const keys = Object.keys(record).toSorted(compareKeys);
|
|
22
|
-
const parts = [];
|
|
23
|
-
for (const key of keys) {
|
|
24
|
-
const raw = record[key];
|
|
25
|
-
if (raw === void 0) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
parts.push(`${JSON.stringify(key)}:${stableStringify(raw)}`);
|
|
29
|
-
}
|
|
30
|
-
return `{${parts.join(",")}}`;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const FLAGS_EVAL_PATH = "__lunora_flags__:eval";
|
|
34
|
-
const flagKind = (value) => {
|
|
35
|
-
const kind = typeof value;
|
|
36
|
-
if (kind === "boolean" || kind === "number" || kind === "string") {
|
|
37
|
-
return kind;
|
|
38
|
-
}
|
|
39
|
-
return "object";
|
|
40
|
-
};
|
|
41
|
-
const flagsReference = { __lunoraRef: FLAGS_EVAL_PATH };
|
|
42
|
-
const serializeContext = (context) => context === void 0 ? "" : stableStringify(context);
|
|
43
|
-
const useFlag = (key, defaultValue, context) => {
|
|
44
|
-
const client = useLunora();
|
|
45
|
-
const type = flagKind(defaultValue);
|
|
46
|
-
const value = shallowRef(defaultValue);
|
|
47
|
-
watch(
|
|
48
|
-
() => `${toValue(key)}\0${serializeContext(toValue(context))}`,
|
|
49
|
-
(_serialized, _previous, onCleanup) => {
|
|
50
|
-
const currentKey = toValue(key);
|
|
51
|
-
const currentContext = toValue(context);
|
|
52
|
-
value.value = defaultValue;
|
|
53
|
-
let unsubscribe;
|
|
54
|
-
try {
|
|
55
|
-
unsubscribe = client.subscribe(flagsReference, { context: currentContext, default: defaultValue, key: currentKey, type }, (next) => {
|
|
56
|
-
value.value = next;
|
|
57
|
-
});
|
|
58
|
-
} catch {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
onCleanup(unsubscribe);
|
|
62
|
-
},
|
|
63
|
-
{ immediate: true }
|
|
64
|
-
);
|
|
65
|
-
return value;
|
|
66
|
-
};
|
|
67
|
-
const useFlags = (flags, context) => {
|
|
68
|
-
const client = useLunora();
|
|
69
|
-
const values = shallowRef(flags);
|
|
70
|
-
const spec = stableStringify(flags);
|
|
71
|
-
watch(
|
|
72
|
-
() => `${spec}\0${serializeContext(toValue(context))}`,
|
|
73
|
-
(_serialized, _previous, onCleanup) => {
|
|
74
|
-
const currentContext = toValue(context);
|
|
75
|
-
values.value = flags;
|
|
76
|
-
const unsubscribes = [];
|
|
77
|
-
for (const [key, defaultValue] of Object.entries(flags)) {
|
|
78
|
-
try {
|
|
79
|
-
unsubscribes.push(
|
|
80
|
-
client.subscribe(flagsReference, { context: currentContext, default: defaultValue, key, type: flagKind(defaultValue) }, (next) => {
|
|
81
|
-
values.value = { ...values.value, [key]: next };
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
} catch {
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
onCleanup(() => {
|
|
88
|
-
for (const unsubscribe of unsubscribes) {
|
|
89
|
-
unsubscribe();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
{ immediate: true }
|
|
94
|
-
);
|
|
95
|
-
return values;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export { useFlag, useFlags };
|